I am trying to FTP files from local distribution build to production using Grunt. I have tested by bash file and it works. I just can't get it to run using grunt.
In my grunt file:
/*global module:false*/
module.exports = function(grunt) {
grunt.initConfig( {
...
exec: {
ftpupload: {
command: 'ftp.sh'
}
}
} );
grunt.loadNpmTasks('grunt-exec');
grunt.registerTask('deploy', ['ftpupload']);
};
I try grunt deploy at the command line and get the following error:
Warning: Task "ftpupload" not found. Use --force to continue.
I try grunt exec at the command line and get the following error:
Running "exec:ftpupload" (exec) task
>> /bin/sh: ftp.sh: command not found
>> Exited with code: 127.
>> Error executing child process: Error: Process exited with code 127.
Warning: Task "exec:ftpupload" failed. Use --force to continue.
The ftp.sh file resides in the same directory as Gruntfile.js.
How can I configure it so that I can run grunt deploy and have the bash script run?
Here are a couple of options to try....
Option 1
Assuming that grunt-exec allows a shell script to be run (...it's not a package I've used before!) reconfigure the
Gruntfile.jsas follows:Note
exec.ftpupload.command- it now includes a./path prefix, as you mention:deployTask now utilizes the semicolon notation, i.e.exec:ftpuploadOption 2
If Option 1 fails for whatever reason use grunt-shell instead of grunt-exec.
Uninstall grunt-exec by running:
$ npm un -D grunt-execInstall grunt-shell by running:
$ npm i -D grunt-shellgrunt-shell utilizes a package named load-grunt-tasks, so you'll need to install that too by running:
$ npm i -D load-grunt-tasksConfigure your
Gruntfile.jsas follows: