Comparing version
54
index.js
@@ -213,56 +213,2 @@ 'use strict'; | ||
/** | ||
* Watch a file, directory, or glob pattern for changes and build a task | ||
* or list of tasks when changes are made. Watch is powered by [chokidar][] | ||
* so arguments can be anything supported by [chokidar.watch](https://github.com/paulmillr/chokidar#api). | ||
* | ||
* ```js | ||
* var watcher = app.watch('templates/pages/*.hbs', ['site']); | ||
* ``` | ||
* @param {String|Array} `glob` Filename, Directory name, or glob pattern to watch | ||
* @param {Object} `options` Additional options to be passed to [chokidar][] | ||
* @param {String|Array|Function} `tasks` Tasks that are passed to `.build` when files in the glob are changed. | ||
* @return {Object} Returns an instance of `FSWatcher` from [chokidar][] | ||
* @api public | ||
*/ | ||
Composer.prototype.watch = function(glob, options/*, fns/tasks */) { | ||
var self = this; | ||
var len = arguments.length - 1, i = 0; | ||
var args = new Array(len + 1); | ||
while (len--) args[i] = arguments[++i]; | ||
args[i] = done; | ||
var opts = {}; | ||
if (typeof options === 'object' && !Array.isArray(options)) { | ||
args.shift(); | ||
opts = utils.extend(opts, options); | ||
} | ||
var building = true; | ||
function done(err) { | ||
building = false; | ||
if (err) console.error(err); | ||
} | ||
var watch = utils.chokidar.watch(glob, opts); | ||
// only contains our `done` function | ||
if (args.length === 1) { | ||
return watch; | ||
} | ||
watch | ||
.on('ready', function() { | ||
building = false; | ||
}) | ||
.on('all', function() { | ||
if (building) return; | ||
building = true; | ||
self.build.apply(self, args); | ||
}); | ||
return watch; | ||
}; | ||
/** | ||
* Expose Composer | ||
@@ -269,0 +215,0 @@ */ |
@@ -28,7 +28,5 @@ 'use strict'; | ||
require('define-property', 'define'); | ||
require('extend-shallow', 'extend'); | ||
require('array-unique', 'unique'); | ||
require('nanoseconds', 'nano'); | ||
require('isobject'); | ||
require('chokidar'); | ||
require('bach'); | ||
@@ -35,0 +33,0 @@ |
{ | ||
"name": "composer", | ||
"description": "API-first task runner with three methods: task, run and watch.", | ||
"version": "0.10.0", | ||
"homepage": "https://github.com/jonschlinkert/composer", | ||
"version": "0.11.0", | ||
"homepage": "https://github.com/doowb/composer", | ||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
@@ -11,5 +11,5 @@ "contributors": [ | ||
], | ||
"repository": "jonschlinkert/composer", | ||
"repository": "doowb/composer", | ||
"bugs": { | ||
"url": "https://github.com/jonschlinkert/composer/issues" | ||
"url": "https://github.com/doowb/composer/issues" | ||
}, | ||
@@ -31,3 +31,2 @@ "license": "MIT", | ||
"bach": "^0.4.1", | ||
"chokidar": "^1.4.2", | ||
"component-emitter": "^1.2.0", | ||
@@ -74,2 +73,5 @@ "define-property": "^0.2.5", | ||
"assemble", | ||
"base", | ||
"base-tasks", | ||
"composer", | ||
"generate", | ||
@@ -81,6 +83,2 @@ "templates", | ||
}, | ||
"reflinks": [ | ||
"chokidar", | ||
"composer" | ||
], | ||
"plugins": [ | ||
@@ -87,0 +85,0 @@ "gulp-format-md" |
@@ -1,5 +0,7 @@ | ||
# composer [](https://www.npmjs.com/package/composer) [](https://travis-ci.org/jonschlinkert/composer) | ||
# composer [](https://www.npmjs.com/package/composer) [](https://travis-ci.org/doowb/composer) | ||
> API-first task runner with three methods: task, run and watch. | ||
**Heads up** `.watch` has been removed as of version `0.11.0`. If you need watch functionality, use [base-tasks](https://github.com/jonschlinkert/base-tasks) and [base-watch](https://github.com/node-base/base-watch). | ||
## Install | ||
@@ -130,19 +132,2 @@ | ||
### [.watch](index.js#L227) | ||
Watch a file, directory, or glob pattern for changes and build a task or list of tasks when changes are made. Watch is powered by [chokidar](https://github.com/paulmillr/chokidar) so arguments can be anything supported by [chokidar.watch](https://github.com/paulmillr/chokidar#api). | ||
**Params** | ||
* `glob` **{String|Array}**: Filename, Directory name, or glob pattern to watch | ||
* `options` **{Object}**: Additional options to be passed to [chokidar](https://github.com/paulmillr/chokidar) | ||
* `tasks` **{String|Array|Function}**: Tasks that are passed to `.build` when files in the glob are changed. | ||
* `returns` **{Object}**: Returns an instance of `FSWatcher` from [chokidar](https://github.com/paulmillr/chokidar) | ||
**Example** | ||
```js | ||
var watcher = app.watch('templates/pages/*.hbs', ['site']); | ||
``` | ||
## Events | ||
@@ -240,2 +225,4 @@ | ||
* [assemble](https://www.npmjs.com/package/assemble): Assemble is a powerful, extendable and easy to use static site generator for node.js. Used… [more](https://www.npmjs.com/package/assemble) | [homepage](https://github.com/assemble/assemble) | ||
* [base](https://www.npmjs.com/package/base): base is the foundation for creating modular, unit testable and highly pluggable node.js applications, starting… [more](https://www.npmjs.com/package/base) | [homepage](https://github.com/node-base/base) | ||
* [base-tasks](https://www.npmjs.com/package/base-tasks): base-methods plugin that provides a very thin wrapper around [https://github.com/jonschlinkert/composer](https://github.com/jonschlinkert/composer) for adding task methods to… [more](https://www.npmjs.com/package/base-tasks) | [homepage](https://github.com/jonschlinkert/base-tasks) | ||
* [generate](https://www.npmjs.com/package/generate): Fast, composable, highly extendable project generator with a user-friendly and expressive API. | [homepage](https://github.com/generate/generate) | ||
@@ -272,2 +259,2 @@ * [templates](https://www.npmjs.com/package/templates): System for creating and managing template collections, and rendering templates with any node.js template engine.… [more](https://www.npmjs.com/package/templates) | [homepage](https://github.com/jonschlinkert/templates) | ||
_This file was generated by [verb](https://github.com/verbose/verb) on January 27, 2016._ | ||
_This file was generated by [verb](https://github.com/verbose/verb) on January 28, 2016._ |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
8
-11.11%26107
-6.02%507
-8.65%257
-4.81%- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed