Use CLI options without passed grunt.cli.tasks. Fixes GH-12.

This prevents the watch task or another task registered to the watch task
from running duplicate watch tasks.
This commit is contained in:
Kyle Robinson Young 2012-11-01 18:08:55 -07:00
parent 0a6f8fcf86
commit 0addd70cca

View File

@ -52,6 +52,8 @@ module.exports = function(grunt) {
var spawned = Object.create(null);
// List of changed / deleted file paths.
grunt.file.watchFiles = {changed: [], deleted: [], added: []};
// Get process.argv options without grunt.cli.tasks to pass to child processes
var cliArgs = grunt.util._.without.apply(null, [[].slice.call(process.argv, 2)].concat(grunt.cli.tasks));
// Call to close this task
var done = this.async();
@ -85,7 +87,7 @@ module.exports = function(grunt) {
// Run from current working dir
opts: {cwd: process.cwd()},
// Run grunt this process uses, append the task to be run and any cli options
args: grunt.util._.union([process.argv[1]].concat(tasks), [].slice.call(process.argv, 2))
args: grunt.util._.union([process.argv[1]].concat(tasks), cliArgs)
}, function(err, res, code) {
// Spawn is done
delete spawned[i];