Pause between Grunt Tasks

Pause for debugging

I blogged a while ago about the Grunt JavaScript task runner, a great way to automate your JavaScript tasks.

On complex projects, with numerous multitasks that display output, it occurred to me that you might want to be able to pause the task runner after each task. You may perhaps need to assess the output or check something, then decide whether or not to continue running the remaining tasks.


I’ve implemented a Grunt plugin (in a slightly unorthodox manner) to facilitate the pausing, “grunt-pause.js“. It uses the hooker to watch for task changes, then fires off a dynamically added task after each change. The inquirer node package then kicks in to prompt the developer to either continue (default), or clear the task queue and end the task runner.

Grunt core

Personally, I think this should be part of the Grunt core. It would be much easier to implement (not hooky hacky), and could be enabled simply with a “—pause” argument on the command line.

If this package gets used, I’ll consider a pull request to Grunt core for version 0.5.0. This package will still be useful for version 0.4.x etc.


npm install grunt-pause ## --save-dev

Add the grunt-pause reference to the very top of your Gruntfile.js:

var pause = require("grunt-pause");

Add the pause init call at the top of the module.exports function of your Gruntfile.js::

module.exports = function (grunt) {

Sample output

Sample screenshot of the console output:

Console Screenshot.


You might not want to have the pause between all tasks, perhaps we could pass an array of exclusions or inclusions when we call pause.init(grunt)?

As always, issues and pull request on the git repo.