Add forceWatchMethod docs. Bump v0.1.3

This commit is contained in:
Kyle Robinson Young 2012-10-28 15:07:13 -07:00
parent 15e95e9c59
commit 8d07323bdb
4 changed files with 98 additions and 67 deletions

View File

@ -1,3 +1,9 @@
v0.1.3:
date: 2012-10-28
changes:
- Better method to spawn the grunt bin
- Bump gaze to v0.2.0. Better handles some events and new option forceWatchMethod
- Only support Node.js >= v0.8
v0.1.2:
date: 2012-10-17
changes:

145
README.md
View File

@ -26,64 +26,9 @@ If the plugin has been installed correctly, running `grunt --help` at the comman
[package.json]: https://npmjs.org/doc/json.html
## The watch task
## The watch-examples task
### Overview
Inside your `Gruntfile.js` file, add a section named `watch`. This section specifies the files to watch, tasks to run when an event occurs and the options used.
### Settings
There are a number of options available. Please review the [minimatch options here](https://github.com/isaacs/minimatch#options). As well as some additional options as follows:
#### tasks
Type: `String|Array`
This defines which tasks to run when a watched file event occurs.
#### options.interrupt
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.
Example:
```js
watch: {
scripts: {
files: '**/*.js',
tasks: ['jshint'],
options: {
interrupt: true
}
}
}
```
#### options.debounceDelay
Type: `Integer`
Default: 500
How long to wait before emitting events in succession for the same filepath and status. For example if your `Gruntfile.js` file was `changed`, a `changed` event will only fire again after the given milliseconds.
Example:
```js
watch: {
scripts: {
files: '**/*.js',
tasks: ['jshint'],
options: {
debounceDelay: 250
}
}
}
```
#### options.interval
Type: `Integer`
Default: 100
The `interval` is passed to `fs.watchFile`. Since `interval` is only used by `fs.watchFile` and this watcher also uses `fs.watch`; it is recommended to ignore this option. *Default is 100ms*.
### Examples
# Examples
```js
// Simple config to run jshint any time a file is added, changed or deleted
@ -119,13 +64,85 @@ grunt.initConfig({
```
## The watch-options task
# Settings
There are a number of options available. Please review the [minimatch options here](https://github.com/isaacs/minimatch#options). As well as some additional options as follows:
## files
Type: `String|Array`
This defines what file patterns this task will watch. Can be a string or an array of files and/or minimatch patterns.
## tasks
Type: `String|Array`
This defines which tasks to run when a watched file event occurs.
## options.interrupt
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.
Example:
```js
watch: {
scripts: {
files: '**/*.js',
tasks: ['jshint'],
options: {
interrupt: true
}
}
}
```
## options.debounceDelay
Type: `Integer`
Default: 500
How long to wait before emitting events in succession for the same filepath and status. For example if your `Gruntfile.js` file was `changed`, a `changed` event will only fire again after the given milliseconds.
Example:
```js
watch: {
scripts: {
files: '**/*.js',
tasks: ['jshint'],
options: {
debounceDelay: 250
}
}
}
```
## options.interval
Type: `Integer`
Default: 100
The `interval` is passed to `fs.watchFile`. Since `interval` is only used by `fs.watchFile` and this watcher also uses `fs.watch`; it is recommended to ignore this option. *Default is 100ms*.
## options.forceWatchMethod
Type: `false|'new'|'old'`
Default: false
Node.js has two file watching methods: 'old' (`fs.watchFile`) which uses stat polling and 'new' (`fs.watch`) which attempts to use the system's built-in watch mechanism. By default, this watch task uses both methods and which ever method responds first will be used for subsequent events.
There may be some setups where you would need to force a specific watch method, such as on networked file system. Set `options.forceWatchMethod: 'old'` to specifically use the old watch method, `fs.watchFile`.
## The watch-overview task
# Overview
Inside your `Gruntfile.js` file, add a section named `watch`. This section specifies the files to watch, tasks to run when an event occurs and the options used.
## Release History
* 2012-10-07 - v0.1.0 - Release watch task Remove spawn from helper Run on Grunt v0.4
* 2012-10-15 - v0.1.1 - Fallback to global grunt bin if local doesnt exist. Fatal if bin cannot be found Update to gaze 0.1.6
* 2012-10-27 - v0.1.3 - Better method to spawn the grunt bin Bump gaze to v0.2.0. Better handles some events and new option forceWatchMethod Only support Node.js >= v0.8
* 2012-10-16 - v0.1.2 - Only spawn a process per task one at a time Add interrupt option to cancel previous spawned process Grunt v0.3 compatibility changes
--
Task submitted by <a href="http://dontkry.com">Kyle Robinson Young</a>.
*Generated on Thu Oct 18 2012 17:23:15.*
* 2012-10-15 - v0.1.1 - Fallback to global grunt bin if local doesnt exist. Fatal if bin cannot be found Update to gaze 0.1.6
* 2012-10-07 - v0.1.0 - Release watch task Remove spawn from helper Run on Grunt v0.4

View File

@ -5,7 +5,7 @@ There are a number of options available. Please review the [minimatch options he
## files
Type: `String|Array`
This defines what file patterns this task will watch. Can be a string or an array of files and/or minimatch patterns.
This defines what file patterns this task will watch. Can be a string or an array of files and/or minimatch patterns.
## tasks
Type: `String|Array`
@ -54,4 +54,12 @@ watch: {
Type: `Integer`
Default: 100
The `interval` is passed to `fs.watchFile`. Since `interval` is only used by `fs.watchFile` and this watcher also uses `fs.watch`; it is recommended to ignore this option. *Default is 100ms*.
The `interval` is passed to `fs.watchFile`. Since `interval` is only used by `fs.watchFile` and this watcher also uses `fs.watch`; it is recommended to ignore this option. *Default is 100ms*.
## options.forceWatchMethod
Type: `false|'new'|'old'`
Default: false
Node.js has two file watching methods: 'old' (`fs.watchFile`) which uses stat polling and 'new' (`fs.watch`) which attempts to use the system's built-in watch mechanism. By default, this watch task uses both methods and which ever method responds first will be used for subsequent events.
There may be some setups where you would need to force a specific watch method, such as on networked file system. Set `options.forceWatchMethod: 'old'` to specifically use the old watch method, `fs.watchFile`.

View File

@ -1,7 +1,7 @@
{
"name": "grunt-contrib-watch",
"description": "Run predefined tasks whenever watched file patterns are added, changed or deleted.",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/gruntjs/grunt-contrib-watch",
"author": {
"name": "Grunt Team",