Issue
I have this grunt file that creates a rpm package for me, how can I create a symlink like this for an example:
link("/usr/local/bin/tams-cli", "/opt/tams-cli/tams-cli.js")
Have not been able to to find that, here below is my source code.
grunt.initConfig({
pkg: grunt.file.readJSON('./package.json'),
easy_rpm: {
options: {
buildArch,
rpmDestination: './built/',
},
release: {
files: [
{
src: ['node_modules/**/*',
'js/**/*',
'cfg/*',
'package.json',
'readme.md',
],
dest: '/opt/tams-cli',
},
{
src: 'tams-cli.js',
dest: '/opt/tams-cli',
mode: 0550,
}
],
excludeFiles: [
'tmp-*',
'./built',
],
},
},
Solution
To create the symlink after the rpm package is installed utilize the postInstallScript
option in your easy_rpm
task. The description for the postInstallScript
reads:
postInstallScript
Array<String>
An array of commands to be executed after the installation. Each element in the array represents a command.
In the Gruntfile.js
excerpt below it utilizes the ln
command to create the symlink using the additional two options:
-s
to make a symbolic link instead of a hard link.-f
to remove existing destination files if they exist already.
Gruntfile.js
grunt.initConfig({
// ...
easy_rpm: {
options: {
postInstallScript: ['ln -s -f /opt/tams-cli/tams-cli.js /usr/local/bin/tams-cli'],
// ..
},
// ...
},
// ...
});
Answered By - RobC Answer Checked By - Mary Flores (WPSolving Volunteer)