← All tools

grunt-shell-spawn

Popularity 65 Updated Network & Systems

Grunt task to run shell commands

npmauto-collected

Installation

npm
npm install -g grunt-shell-spawn

Install with npm.

grunt-shell-spawn [](https://travis-ci.org/jeking3/grunt-shell-spawn) [](https://ci.appveyor.com/project/jeking3/grunt-shell-spawn/branch/master)

A fork of [sindresorhus][1]'s [grunt-shell][2] with support for background processes. (e.g.: start a compass watch in the background)

This plugin lets you:

  • Run processes synchronously or asynchronously.
  • Process stdout and stderr using functions.
  • Run a function when an asynchronous process ends that gets the exit code.
  • Kill an asynchronous process.

Requirements

  • node.js 16.x or later
  • grunt 1.6 or later

Install

npm install grunt-shell-spawn --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with:

grunt.loadNpmTasks('grunt-shell-spawn');

Examples

#### Simple task:

Let's take for example launching a compass watch in background:

shell: {
    command: 'compass watch',
    options: {
        async: true
    }
}

#### Multitask:

shell: {
    compassWatch: {
        command: 'compass watch',
        options: {
            async: true,
            execOptions: {
                cwd: './src/www/'
           }
       }
    },
    coffeeCompile: {
        command: 'coffee -b -c -o /out /src',

async: false, execOptions: { cwd: './src/www/' } } }, options: { stdout: true, stderr: true, failOnError: true } }


#### Custom callbacks:

Works in synchronous or asynchronous mode.