JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1898
  • Score
    100M100P100Q118510F

Better shell commands for grunt. Background/parallel run

Package Exports

  • grunt-bg-shell

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (grunt-bg-shell) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

grunt-bg-shell

Better shell commands for grunt. Background/parallel run

If you want to run compass watch, coffee --watch --output lib/ src/ and forever server.js at the same time.

Install

$ npm i grunt-bg-shell --save-dev

Using

module.exports = function (grunt) {
  grunt.initConfig({
    bgShell: {
      _defaults: {
        bg: true
      },
      
      watchCompass: {
        cmd: 'compass watch'
      },
      watchCoffee: {
        cmd: 'coffee --watch --output lib/ src/'
      },
      runNode: {
        cmd: 'node server.js',
        bg: false
      }
    }
  });
  
  
  grunt.registerTask('default', 'bgShell:watchCompass bgShell:watchCoffee bgShell:runNode');
};

Important!

In example above all shell commands go to background. But not the last one. We tell grunt to run till bgShell:runNode runs

Options

bgShell: {
  lsTasks: {
    cmd: 'ls -la',
    execOpts: {
      cwd: './tasks'
    },
    stdout: true,
    stderr: true,
    bg: false,
    fail: false,
    done: function(){}
  }     
}
  • cmd: command to execute
  • execOpts: options for child_process.exec
  • stdout: true, false or function(out){}
  • stderr: true, false or function(err){}
  • bg: background execution
  • fail: fail grunt on error
  • done: callback after execution function(err, stdout, stderr){}

Override defaults

bgShell: {
  _defaults: {
    execOpts: null,
    stdout: true,
    stderr: true,
    bg: false,
    fail: false,
    done: function (err, stdout, stderr) {
    }
  },
}

Developing

You need to install grunt globally:

$ npm i -g grunt
  • Watch coffee:
$ grunt