Grunt task for executing shell commands.
Grunt plugin for executing shell commands.
Install grunt-exec using npm:
$ npm install grunt-exec --save-dev
Then add this line to your project's Gruntfile.js:
This plugin is a multi task, meaning that grunt will automatically iterate over all exec targets if a target is not specified.
If the exit code generated by the specified shell command is greater than 0, grunt-exec will assume an error has occurred and will abort grunt immediately.
true, stdout will be printed. Defaults to
true, stderr will be printed. Defaults to
0. Can be an array for multiple allowed exit codes.
child_process.exec. Defaults to a noop.
If the configuration is instead a simple
string, it will be
interpreted as a full command itself:
exec:echo_something: 'echo "This is something"'
If you plan on doing advanced stuff with grunt-exec, you'll most likely be using
functions for the
command property of your exec targets. This section details
a couple of helpful tips about command functions that could help make your life
Command functions can be called with arbitrary arguments. Let's say we have the following exec target that echoes a formatted name:
exec:echo_name:var formattedName =lastNametoUpperCasefirstNametoUpperCasejoin', ';return 'echo ' + formattedName;
In order to get
SIMPSON, HOMER echoed, you'd run
grunt exec:echo_name:homer:simpson from the command line.
All command functions are called in the context of the
grunt object that they
are being ran with. This means you can access the
grunt object through
The following examples are available in grunt-exec's Gruntfile.
gruntinitConfigexec:remove_logs:command: 'rm -f *.log'stdout: falsestderr: falselist_files:cmd: 'ls -l **'list_all_files: 'ls -la'echo_grunt_version:return 'echo ' + thisversion;echo_name:var formattedName =lastNametoUpperCasefirstNametoUpperCasejoin', ';return 'echo ' + formattedName;;
$ cd grunt-exec$ npm test
Found a bug? Create an issue on GitHub.
For transparency and insight into the release cycle, releases will be numbered with the follow format:
And constructed with the following guidelines:
For more information on semantic versioning, please visit http://semver.org/.