Docs for nospawn
This commit is contained in:
parent
855396972a
commit
ad67808cc9
@ -45,4 +45,8 @@ Yes. Although `grunt-contrib-watch` is a replacement watch task for Grunt v0.4,
|
||||
Likely because of an enthusiastic pattern trying to watch thousands of files. Such as `'**/*.js'` but forgetting to exclude the `node_modules` folder with `'!node_modules/**/*.js'`. Try grouping your files within a subfolder or be more explicit with your file matching pattern.
|
||||
|
||||
## Why spawn as child processes as a default?
|
||||
TODO: Write this.
|
||||
The goal of this watch task is as files are changed, run tasks as if they were triggered by the user themself. Each time a user runs `grunt` a process is spawned and tasks are ran in succession. In an effort to keep the experience consistent and continualy produce expected results, this watch task spawns tasks as child processes by default.
|
||||
|
||||
Sandboxing task runs also allows this watch task to run more stable over long periods of time. As well as more efficiently with more complex tasks and file structures.
|
||||
|
||||
Spawning does cause a performance hit (usually 500ms for most environments). It also cripples tasks that rely on the watch task to share the context with each subsequent run (i.e., reload tasks). If you would like a faster watch task or need to share the context please set the `nospawn` option to `true`. Just be aware that with this option enabled, the watch task is more prone to failure.
|
||||
|
@ -13,13 +13,26 @@ Type: `String|Array`
|
||||
This defines which tasks to run when a watched file event occurs.
|
||||
|
||||
## options.nospawn
|
||||
Type: `boolean`
|
||||
Type: `Boolean`
|
||||
Default: false
|
||||
|
||||
TODO: Write this.
|
||||
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.
|
||||
|
||||
Example:
|
||||
```js
|
||||
watch: {
|
||||
scripts: {
|
||||
files: ['**/*.js'],
|
||||
tasks: ['livereload'],
|
||||
options: {
|
||||
nospawn: true
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## options.interrupt
|
||||
Type: `boolean`
|
||||
Type: `Boolean`
|
||||
Default: false
|
||||
|
||||
As files are modified this watch task will spawn tasks in child processes. The default behavior will only spawn a new child process per target when the previous process has finished. Set the `interrupt` option to true to terminate the previous process and spawn a new one upon later changes.
|
||||
|
Loading…
Reference in New Issue
Block a user