Grunt task to run shell commands
npm install grunt-shell-spawn2compass watch in the background)
0.1.3.
compass watch in background:
javascript
shell: {
command: 'compass watch',
options: {
async: true
}
}
`
#### Multitask:
`javascript
shell: {
compassWatch: {
command: 'compass watch',
options: {
async: true,
execOptions: {
cwd: './src/www/'
}
}
},
coffeeCompile: {
command: 'coffee -b -c -o /out /src',
options: {
async: false,
execOptions: {
cwd: './src/www/'
}
}
},
options: {
stdout: true,
stderr: true,
failOnError: true
}
}
`
#### Custom callbacks:
Works in synchronous or asynchronous mode.
`
asyncWithCallbacks: {
command: 'sleep 3 & echo HELLO & sleep 1 & echo WORLD & sleep 2',
options: {
async: true,
stdout: function(data) { / ... / },
stderr: function(data) { / ... / },
callback: function(exitCode, stdOutStr, stdErrStr, done) {
done();
}
}
},
`
#### Killing an async process
Stop a running async task with the :kill task argument.
`
server: {
command: 'redis-server',
options: {
async: true,
}
},
`
> grunt shell:server shell:somethingElse shell:server:kill
The process will be killed with a SIGKILL.
Please note that processes that are not killed will continue running even after grunt finishes, unless explicitly terminated using :kill. This means it is required to use :kill` to clean up any processes you started, unless you want them to continue running in the background.