Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grunt-contrib-watch

Package Overview
Dependencies
Maintainers
3
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-contrib-watch - npm Package Compare versions

Comparing version 0.1.4 to 0.2.0-a

.gitattributes

2

docs/watch-faqs.md
# FAQs
## How do I fix the error `EMFILE: Too many opened files.`?
This is because of your system's max opened file limit. For OSX the default is very low (256). Increase your limit with `ulimit -n 10480`, the number being the new max limit. If you're still running into issues then consider setting the option `forceWatchMethod: 'old'` to use the older and slower stat polling watch method.
This is because of your system's max opened file limit. For OSX the default is very low (256). Temporarily increase your limit with `ulimit -n 10480`, the number being the new max limit.

@@ -58,9 +58,1 @@ # Settings

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`.

@@ -38,3 +38,3 @@ /*

nodeunit: {
tests: ['test/**/*_test.js']
tests: ['test/tasks/*_test.js']
}

@@ -41,0 +41,0 @@

{
"name": "grunt-contrib-watch",
"description": "Run predefined tasks whenever watched file patterns are added, changed or deleted.",
"version": "0.1.4",
"version": "0.2.0a",
"homepage": "https://github.com/gruntjs/grunt-contrib-watch",

@@ -31,13 +31,14 @@ "author": {

"dependencies": {
"gaze": "~0.2.0"
"gaze": "~0.3.0"
},
"devDependencies": {
"grunt-contrib-jshint": "~0.1.0",
"grunt-contrib-nodeunit": "~0.1.0",
"grunt-contrib-internal": "*",
"grunt": "~0.4.0a"
"grunt-contrib-nodeunit": "~0.1.1",
"grunt-contrib-internal": "~0.1.1",
"grunt": "~0.4.0rc4"
},
"keywords": [
"gruntplugin", "watch"
"gruntplugin",
"watch"
]
}

@@ -5,31 +5,16 @@ # grunt-contrib-watch [![Build Status](https://secure.travis-ci.org/gruntjs/grunt-contrib-watch.png?branch=master)](http://travis-ci.org/gruntjs/grunt-contrib-watch)

_Note that this plugin has not yet been released, and only works with the latest bleeding-edge, in-development version of grunt. See the [When will I be able to use in-development feature 'X'?](https://github.com/gruntjs/grunt/blob/devel/docs/faq.md#when-will-i-be-able-to-use-in-development-feature-x) FAQ entry for more information._
## Grunt Compability
* `grunt-contrib-watch@0.1.x` is compatible with `grunt >= 0.3.x`
* `grunt-contrib-watch@0.2.x` will be compatible with `grunt >= 0.4.x`
## Getting Started
_If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide._
If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide, as it explains how to create a [gruntfile][Getting Started] as well as install and use grunt plugins. Once you're familiar with that process, install this plugin with this command:
From the same directory as your project's [Gruntfile][Getting Started] and [package.json][], install this plugin with the following command:
```bash
```shell
npm install grunt-contrib-watch --save-dev
```
Once that's done, add this line to your project's Gruntfile:
```js
grunt.loadNpmTasks('grunt-contrib-watch');
```
If the plugin has been installed correctly, running `grunt --help` at the command line should list the newly-installed plugin's task or tasks. In addition, the plugin should be listed in package.json as a `devDependency`, which ensures that it will be installed whenever the `npm install` command is run.
[grunt]: http://gruntjs.com/
[Getting Started]: https://github.com/gruntjs/grunt/blob/devel/docs/getting_started.md
[package.json]: https://npmjs.org/doc/json.html
## The watch task
## Watch task
_Run this task with the `grunt watch` command._

@@ -97,10 +82,2 @@ ### Overview

#### 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`.
### Examples

@@ -144,12 +121,13 @@

* 2012-11-19 - v0.1.5 - Allow watch task to be renamed. Use grunt.util.spawn "grunt" option.
* 2012-10-31 - v0.1.4 - Prevent watch from spawning duplicate watch tasks
* 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
* 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
* 2012-12-14   v0.2.0   Conversion to grunt v0.4 conventions. Remove node v0.6 and grunt v0.3 support. Allow watch task to be renamed. Use grunt.util.spawn "grunt" option. Updated to gaze@0.3.0, forceWatchMethod option removed.
* 2012-10-31   v0.1.4   Prevent watch from spawning duplicate watch tasks
* 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
* 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
--
Task submitted by <a href="http://dontkry.com">Kyle Robinson Young</a>.
---
*Generated on Mon Nov 19 2012 12:58:44.*
Task submitted by [Kyle Robinson Young](http://dontkry.com)
*This file was generated on Fri Dec 14 2012 21:19:48.*

@@ -12,5 +12,2 @@ /*

// TODO: ditch this when grunt v0.4 is released
grunt.util = grunt.util || grunt.utils;
var path = require('path');

@@ -20,6 +17,2 @@ var fs = require('fs');

// In Nodejs 0.8.0, existsSync moved from path -> fs.
// TODO: When 0.4 is release, use grunt.file.exists
fs.existsSync = fs.existsSync || path.existsSync;
// Default options for the watch task

@@ -33,2 +26,3 @@ var defaults = {

this.requiresConfig(name);
// Build an array of files/tasks objects

@@ -39,2 +33,3 @@ var watch = grunt.config(name);

});
targets = targets.map(function(target) {

@@ -54,8 +49,12 @@ // Fail if any required config properties have been omitted

var waiting = 'Waiting...';
// File changes to be logged.
var changedFiles = Object.create(null);
// Keep track of spawns per tasks
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

@@ -76,5 +75,7 @@ var cliArgs = grunt.util._.without.apply(null, [[].slice.call(process.argv, 2)].concat(grunt.cli.tasks));

}
// Only spawn one at a time unless interrupt is specified
if (!spawned[i]) {
grunt.log.ok();
var fileArray = Object.keys(changedFiles);

@@ -85,12 +86,14 @@ fileArray.forEach(function(filepath) {

});
// Reset changedFiles
changedFiles = Object.create(null);
// Spawn the tasks as a child process
spawned[i] = grunt.util.spawn({
// Use the node that spawned this process
cmd: process.argv[0],
// Run from current working dir
opts: {cwd: process.cwd()},
// Spawn with the grunt bin
grunt: true,
// Run from current working dir and inherit stdio from process
opts: {cwd: process.cwd(), stdio: 'inherit'},
// Run grunt this process uses, append the task to be run and any cli options
args: grunt.util._.union([process.argv[1]].concat(tasks), cliArgs)
args: grunt.util._.union(tasks, cliArgs)
}, function(err, res, code) {

@@ -101,8 +104,2 @@ // Spawn is done

});
// Display stdout/stderr immediately
spawned[i].stdout.on('data', function(buf) { grunt.log.write(String(buf)); });
spawned[i].stderr.on('data', function(buf) {
buf = grunt.log.uncolor(String(buf));
if (!grunt.util._.isBlank(buf)) { grunt.log.error(buf); }
});
}

@@ -117,4 +114,6 @@ }, 250);

var patterns = grunt.util._.chain(target.files).flatten().uniq().value();
// Default options per target
var options = grunt.util._.defaults(target.options || {}, defaults);
// Create watcher per target

@@ -126,2 +125,3 @@ var gaze = new Gaze(patterns, options, function(err) {

}
// On changed/added/deleted

@@ -133,2 +133,3 @@ this.on('all', function(status, filepath) {

});
// On watcher error

@@ -135,0 +136,0 @@ this.on('error', function(err) { grunt.log.error(err); });

@@ -6,14 +6,3 @@ 'use strict';

var fs = require('fs');
grunt.util = grunt.util || grunt.utils;
// Node v0.6 compat
path.sep = path.sep || path.normalize('/');
// In case the grunt being used to test is different than the grunt being
// tested, initialize the task and config subsystems.
if (grunt.task.searchDirs.length === 0) {
grunt.task.init([]);
grunt.config.init({});
}
// Where our fixtures are

@@ -101,4 +90,15 @@ var fixtures = path.join(__dirname, '..', 'fixtures');

// clean up before and after
function cleanUp() {
[
path.join(fixtures, 'multiTargets', 'node_modules'),
path.join(fixtures, 'oneTarget', 'node_modules'),
].forEach(function(filepath) {
if (grunt.file.exists(filepath)) { grunt.file.delete(filepath); }
});
}
exports.watchConfig = {
setUp: function(done) {
cleanUp();
fs.symlinkSync(path.join(__dirname, '../../node_modules'), path.join(fixtures, 'multiTargets', 'node_modules'));

@@ -109,4 +109,3 @@ fs.symlinkSync(path.join(__dirname, '../../node_modules'), path.join(fixtures, 'oneTarget', 'node_modules'));

tearDown: function(done) {
grunt.file.delete(path.join(fixtures, 'multiTargets', 'node_modules'));
grunt.file.delete(path.join(fixtures, 'oneTarget', 'node_modules'));
cleanUp();
done();

@@ -113,0 +112,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc