jharding / grunt-exec

Grunt plugin for executing shell commands.
https://npmjs.org/package/grunt-exec
Other
248 stars 47 forks source link

Run command after exit #25

Closed raddevon closed 11 years ago

raddevon commented 11 years ago

I have a task that runs a grunt watch, and I would like to execute a command after that watch task has been exited. Is this possible with grunt-exec?

I want grunt-exec to start my MAMP server when my development task is run and then stop it after the watch is exited with Ctrl-C.

jharding commented 11 years ago

You should be able to do something like the following in your Gruntfile:

module.exports = function(grunt) {
  grunt.initConfig({
    watch: { /* ... */ },

    exec: {
      start: { /* ... */ },
      stop :{ /* ... */ }
    }
  });

  grunt.registerTaslk('myTask', ['exec:start', 'watch', 'exec:stop']);
};
raddevon commented 11 years ago

@jharding That sounds perfect! I wasn't sure if Control-C would exit the entire task or just the currently running sub-task. Thank you.