grunt-bg-shell
Improve your workflow by running commands in the background and in parallel using Grunt.
Getting Started
Note: This plugin requires Grunt >=0.4.0
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-bg-shell --save-dev
Then add the task to your Gruntfile.js
with this line:
grunt;
Sample Usage
For example, say you want to run your node server and also compile coffeescript and sass/scss files all in the same terminal. You could acheive that with the following config:
module { grunt; grunt;};
Available Options
bgShell: lsTasks: cmd: 'ls -la' // or function(){return 'ls -la'} execOpts: cwd: './tasks' stdout: true stderr: true bg: false fail: false {}
cmd
: command to execute orfunction(){}
that returns a command to executeexecOpts
: options forchild_process.exec
. IfexecOpts.maxBuffer
set tofalse
,0
,NaN
orInfinite
it won't buffer stdout and stderr fordone
callbackstdout
:true
,false
orfunction(out){}
stderr
:true
,false
orfunction(err){}
bg
: background executionfail
: fail grunt on errordone
: callback after executionfunction(err, stdout, stderr){}
Default Options
bgShell: _defaults: execOpts: {} stdout: true stderr: true bg: false fail: false { }
Troubleshooting
If you get
Error: stdout maxBuffer exceeded
You should set execOpts.maxBuffer
to false
. But you won't get stdout and strerr in done
callback
Example:
bgShell: lsTasks: cmd: 'ls -la' execOpts: maxBuffer: false { // process your stdout chunk } { // process your stderr chunk } { // stdout === null // stderr === null }