Change nospawn option to spawn. Closes GH-81.

This commit is contained in:
Kyle Robinson Young 2013-07-11 12:42:17 -07:00
parent 44edaf2a30
commit 09f4854459
6 changed files with 14 additions and 9 deletions

View File

@ -12,25 +12,27 @@ Type: `String|Array`
This defines which tasks to run when a watched file event occurs.
## options.nospawn
## options.spawn
Type: `Boolean`
Default: false
Default: true
This instructs the watch task to not spawn task runs in a child process. Setting this option also speeds up the reaction time of the watch (usually 500ms faster for most) and allows subsequent task runs to share the same context (i.e., using a reload task). Not spawning task runs can make the watch more prone to failing so please use as needed.
Whether to spawn task runs in a child process. Setting this option to `false` speeds up the reaction time of the watch (usually 500ms faster for most) and allows subsequent task runs to share the same context. Not spawning task runs can make the watch more prone to failing so please use as needed.
Example:
```js
watch: {
scripts: {
files: ['**/*.js'],
tasks: ['livereload'],
tasks: ['jshint'],
options: {
nospawn: true,
spawn: false,
},
},
},
```
*For backwards compatibility the option `nospawn` is still available and will do the opposite of `spawn`.*
## options.interrupt
Type: `Boolean`
Default: false

View File

@ -43,7 +43,7 @@ module.exports = function(grunt) {
// If no tasks just call done to trigger potential livereload
if (self.tasks.length < 1) { return done(); }
if (self.options.nospawn === true) {
if (self.options.spawn === false || self.options.nospawn === true) {
grunt.task.run(self.tasks);
done();
} else {

View File

@ -178,7 +178,9 @@ module.exports = function(grunt) {
grunt.util.async.forEachSeries(self.queue, function(name, next) {
var tr = self.targets[name];
if (!tr) { return next(); }
if (tr.options.nospawn) { shouldComplete = false; }
if (tr.options.spawn === false || tr.options.nospawn === true) {
shouldComplete = false;
}
tr.run(next);
}, function() {
if (shouldComplete) {

View File

@ -73,6 +73,7 @@ module.exports = function(grunt) {
var targets = taskrun.init(name, {
interrupt: false,
nospawn: false,
spawn: true,
atBegin: false,
event: ['all'],
target: target,

View File

@ -4,7 +4,7 @@ module.exports = function(grunt) {
grunt.initConfig({
watch: {
options: {
nospawn: true,
spawn: false,
},
warn: {
files: ['lib/*.js'],

View File

@ -25,7 +25,7 @@ module.exports = function(grunt) {
files: ['lib/*.js'],
tasks: ['before'],
options: {
nospawn: true,
spawn: false,
livereload: 1337,
},
},