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.3 to 0.1.4

.editorconfig

74

CONTRIBUTING.md

@@ -1,73 +0,1 @@

[Grunt homepage](http://gruntjs.com/) | [Documentation table of contents](https://github.com/gruntjs/grunt/blob/devel/docs/toc.md)
# Contributing to grunt
There are a number of grunt projects.
* [grunt](https://github.com/gruntjs/grunt) - the main grunt project
* [gruntjs.com](https://github.com/gruntjs/gruntjs.com) - the gruntjs.com website
* [grunt-contrib collection](https://github.com/gruntjs/grunt-contrib) - a collection of all grunt "contrib" plugins
In addition, each individual grunt-contrib plugin is a separate repository listed on the [gruntjs org homepage](https://github.com/gruntjs).
## Filing issues
If something isn't working like you think it should, please read the documentation first. If you'd like to chat with someone, [pop into IRC](#discussing-grunt) and ask your question there.
The best way to ensure an issue gets addressed is to file it in the appropriate issues tracker.
**If there's an issue with a specific grunt-contrib plugin:**
Please file an issue on that plugin's issues tracker.
**If you'd like to contribute a new plugin:**
Please file an issue on the [grunt-contrib collection issues tracker](https://github.com/gruntjs/grunt-contrib/issues). We don't accept all plugins, but we'll certainly consider yours.
**If there's an issue with the [website](http://gruntjs.com/):**
Please file an issue on the [gruntjs.com website issues tracker](https://github.com/gruntjs/gruntjs.com/issues).
**If there's an issue that isn't specific to any of the above:**
Please file an issue on the [grunt issues tracker](https://github.com/gruntjs/grunt/issues).
### Simplify the issue
Try to [reduce your code](http://www.webkit.org/quality/reduction.html) to the bare minimum required to reproduce the issue. This makes it much easier (and much faster) to isolate and fix the issue.
### Explain the issue
If we can't reproduce the issue, we can't fix it. Please list the exact steps required to reproduce the issue. Include versions of your OS, Node.js, grunt, etc. Include relevant logs or sample code.
## Discussing grunt
Join the [freenode](http://freenode.net/) IRC #grunt channel. We've got a bot and everything.
_No private messages, please._
## Modifying grunt
First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed.
1. Fork and clone the repo.
1. Check out the correct branch. Currently, grunt development happens in the `devel` branch.
1. Run `npm install` to install all grunt dependencies.
1. Run `npm link` to put the dev version of grunt in the system path (this is only needed for developing grunt, not for plugins or the website).
1. Run `grunt` to grunt grunt.
Assuming that you don't see any red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing breaks.
### Submitting pull requests
1. Create a new branch, please don't work in your `master` or `devel` branch directly.
1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail.
1. Fix stuff.
1. Run `grunt` to see if the tests pass. Repeat steps 2-4 until done.
1. Update the documentation to reflect any changes.
1. Push to your fork and submit a pull request.
### Syntax
* Two space indents. Don't use tabs anywhere. Use `\t` if you need a tab character in a string.
* No trailing whitespace, except in markdown files where a linebreak must be forced.
* Don't go overboard with the whitespace.
* No more than [one assignment](http://benalman.com/news/2012/05/multiple-var-statements-javascript/) per `var` statement.
* Delimit strings with single-quotes `'`, not double-quotes `"`.
* Prefer `if` and `else` to ["clever"](http://programmers.stackexchange.com/a/25281) uses of `? :` conditional or `||`, `&&` logical operators.
* Comments are great. Just put them _before_ the line of code, _not_ at the _end_ of the line.
* **When in doubt, follow the conventions you see used in the source already.**
### Reverting back to the "official" grunt
If you've used `npm link` to put a dev version of grunt in the system path and, for some reason, need to revert back to the current official grunt release, just reinstall grunt globally with `npm install -g grunt`
Please see the [Contributing to grunt](http://gruntjs.com/contributing) guide for information on contributing to this project.

@@ -51,9 +51,5 @@ /*

// Whenever the "test" task is run, first clean the "tmp" dir, then run this
// plugin's task(s), then test the result.
grunt.registerTask('test', ['nodeunit']);
// By default, lint and run all tests.
grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
grunt.registerTask('default', ['jshint', 'nodeunit', 'build-contrib']);
};
{
"name": "grunt-contrib-watch",
"description": "Run predefined tasks whenever watched file patterns are added, changed or deleted.",
"version": "0.1.3",
"version": "0.1.4",
"homepage": "https://github.com/gruntjs/grunt-contrib-watch",

@@ -23,3 +23,3 @@ "author": {

],
"main": "grunt.js",
"main": "Gruntfile.js",
"engines": {

@@ -29,3 +29,3 @@ "node": ">= 0.8.0"

"scripts": {
"test": "grunt test -v"
"test": "grunt nodeunit -v"
},

@@ -36,4 +36,4 @@ "dependencies": {

"devDependencies": {
"grunt-contrib-jshint": "0.1.0",
"grunt-contrib-nodeunit": "0.1.0",
"grunt-contrib-jshint": "~0.1.0",
"grunt-contrib-nodeunit": "~0.1.0",
"grunt-contrib-internal": "*",

@@ -40,0 +40,0 @@ "grunt": "~0.4.0a"

@@ -7,2 +7,6 @@ # 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)

## 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

@@ -30,47 +34,12 @@ _If you haven't used [grunt][] before, be sure to check out the [Getting Started][] guide._

## The watch-examples task
## The watch task
# Examples
### Overview
```js
// Simple config to run jshint any time a file is added, changed or deleted
grunt.initConfig({
watch: {
files: '**/*',
tasks: ['jshint']
}
});
```
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
```js
// Advanced config. Run specific tasks when specific files are added, changed or deleted.
grunt.initConfig({
watch: {
gruntfile: {
files: 'Gruntfile.js',
tasks: ['jshint:gruntfile'],
options: {
nocase: true
}
},
src: {
files: ['lib/*.js', 'css/**/*.scss', '!lib/dontwatch.js'],
tasks: ['default']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'qunit']
}
}
});
```
## 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
#### files
Type: `String|Array`

@@ -80,3 +49,3 @@

## tasks
#### tasks
Type: `String|Array`

@@ -86,3 +55,3 @@

## options.interrupt
#### options.interrupt
Type: `boolean`

@@ -106,3 +75,3 @@ Default: false

## options.debounceDelay
#### options.debounceDelay
Type: `Integer`

@@ -126,3 +95,3 @@ Default: 500

## options.interval
#### options.interval
Type: `Integer`

@@ -133,3 +102,3 @@ Default: 100

## options.forceWatchMethod
#### options.forceWatchMethod
Type: `false|'new'|'old'`

@@ -142,12 +111,42 @@ Default: false

### Examples
## The watch-overview task
```js
// Simple config to run jshint any time a file is added, changed or deleted
grunt.initConfig({
watch: {
files: '**/*',
tasks: ['jshint']
}
});
```
# Overview
```js
// Advanced config. Run specific tasks when specific files are added, changed or deleted.
grunt.initConfig({
watch: {
gruntfile: {
files: 'Gruntfile.js',
tasks: ['jshint:gruntfile'],
options: {
nocase: true
}
},
src: {
files: ['lib/*.js', 'css/**/*.scss', '!lib/dontwatch.js'],
tasks: ['default']
},
test: {
files: '<%= jshint.test.src %>',
tasks: ['jshint:test', 'qunit']
}
}
});
```
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-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

@@ -157,1 +156,6 @@ * 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-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.*

@@ -29,5 +29,6 @@ /*

grunt.registerTask('watch', 'Run predefined tasks whenever watched files change.', function(target) {
this.requiresConfig('watch');
var name = this.name || 'watch';
this.requiresConfig(name);
// Build an array of files/tasks objects
var watch = grunt.config('watch');
var watch = grunt.config(name);
var targets = target ? [target] : Object.keys(watch).filter(function(key) {

@@ -38,3 +39,3 @@ return typeof watch[key] !== 'string' && !Array.isArray(watch[key]);

// Fail if any required config properties have been omitted
target = ['watch', target];
target = [name, target];
this.requiresConfig(target.concat('files'), target.concat('tasks'));

@@ -57,2 +58,4 @@ return grunt.config(target);

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));

@@ -76,7 +79,4 @@ // Call to close this task

fileArray.forEach(function(filepath) {
var status = changedFiles[filepath];
// Log which file has changed, and how.
grunt.log.ok('File "' + filepath + '" ' + status + '.');
// Add filepath to grunt.file.watchFiles for grunt.file.expand* methods.
grunt.file.watchFiles[status].push(filepath);
grunt.log.ok('File "' + filepath + '" ' + changedFiles[filepath] + '.');
});

@@ -92,3 +92,3 @@ // Reset changedFiles

// 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) {

@@ -101,3 +101,6 @@ // Spawn is done

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

@@ -104,0 +107,0 @@ }, 250);

@@ -9,2 +9,3 @@ module.exports = function(grunt) {

interrupt: { message: 'I want to be interrupted', wait: 5000 },
fail: { fail: 1, message: 'This task should fail' }
},

@@ -28,2 +29,6 @@ watch: {

options: { interrupt: true }
},
fail: {
files: ['lib/fail.js'],
tasks: ['echo:fail']
}

@@ -30,0 +35,0 @@ }

@@ -14,8 +14,13 @@ /*

var wait = this.data.wait || 0;
var fail = this.data.fail || false;
var done = this.async();
// After a given time print a message
// After a given time print a message or fail
setTimeout(function() {
grunt.log.writeln(msg);
done();
if (fail) {
grunt.fail.fatal(msg, fail);
} else {
grunt.log.writeln(msg);
done();
}
}, wait);

@@ -22,0 +27,0 @@

@@ -5,2 +5,3 @@ 'use strict';

var path = require('path');
var fs = require('fs');
grunt.util = grunt.util || grunt.utils;

@@ -101,2 +102,12 @@

exports.watchConfig = {
setUp: function(done) {
fs.symlinkSync(path.join(__dirname, '../../node_modules'), path.join(fixtures, 'multiTargets', 'node_modules'));
fs.symlinkSync(path.join(__dirname, '../../node_modules'), path.join(fixtures, 'oneTarget', 'node_modules'));
done();
},
tearDown: function(done) {
grunt.file.delete(path.join(fixtures, 'multiTargets', 'node_modules'));
grunt.file.delete(path.join(fixtures, 'oneTarget', 'node_modules'));
done();
},
oneTarget: function(test) {

@@ -174,3 +185,16 @@ test.expect(2);

});
},
failingTask: function(test) {
test.expect(2);
var cwd = path.resolve(fixtures, 'multiTargets');
var assertWatch = assertTask('watch', {cwd:cwd});
assertWatch(function() {
grunt.file.write(path.join(cwd, 'lib', 'fail.js'), 'var fail = false;');
}, function(result) {
verboseLog(result);
test.ok(result.toLowerCase().indexOf('fatal') !== -1, 'Task should have been fatal.');
test.equal(grunt.util._(result).count('Waiting...'), 2, 'Should have displayed "Wating..." twice');
test.done();
});
}
};

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