Coder Social home page Coder Social logo

grunt-shell-spawn's Introduction

grunt-shell-spawn

A fork of sindresorhus's grunt-shell with support for background processes.

(e.g.: start a compass watch in the background)


Needs a new maintainer!


This plugin requires grunt >= 0.4.x. For grunt 0.3.x, use version 0.1.3.

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',
        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.

License

MIT License (c) Sindre Sorhus

grunt-shell-spawn's People

Contributors

benaghaeipour avatar cri5ti avatar dandv avatar dignifiedquire avatar hurrymaplelad avatar jansegre avatar jonhoo avatar landau avatar mboudreau avatar mgs255 avatar mhluska avatar sindresorhus avatar suisho avatar yannickcr avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.