undertaker-registry
Advanced tools
Comparing version 1.0.1 to 2.0.0
@@ -11,2 +11,3 @@ 'use strict'; | ||
/* eslint no-unused-vars: 0 */ | ||
DefaultRegistry.prototype.init = function init(taker) {}; | ||
@@ -19,3 +20,3 @@ | ||
DefaultRegistry.prototype.set = function set(name, fn) { | ||
return this._tasks[name] = fn; | ||
return (this._tasks[name] = fn); | ||
}; | ||
@@ -26,3 +27,3 @@ | ||
return Object.keys(this._tasks).reduce(function(tasks, name) { | ||
return Object.keys(this._tasks).reduce(function (tasks, name) { | ||
tasks[name] = self.get(name); | ||
@@ -29,0 +30,0 @@ return tasks; |
{ | ||
"name": "undertaker-registry", | ||
"version": "1.0.1", | ||
"version": "2.0.0", | ||
"description": "Default registry in gulp 4.", | ||
@@ -12,3 +12,3 @@ "author": "Gulp Team <team@gulpjs.com> (http://gulpjs.com/)", | ||
"engines": { | ||
"node": ">= 0.10" | ||
"node": ">= 10.13.0" | ||
}, | ||
@@ -21,18 +21,23 @@ "main": "index.js", | ||
"scripts": { | ||
"lint": "eslint . && jscs index.js test/", | ||
"lint": "eslint .", | ||
"pretest": "npm run lint", | ||
"test": "mocha --async-only", | ||
"cover": "istanbul cover _mocha --report lcovonly", | ||
"coveralls": "npm run cover && istanbul-coveralls" | ||
"test": "nyc mocha --async-only" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^1.7.3", | ||
"eslint-config-gulp": "^2.0.0", | ||
"expect": "^1.19.0", | ||
"istanbul": "^0.4.3", | ||
"istanbul-coveralls": "^1.0.3", | ||
"jscs": "^2.3.5", | ||
"jscs-preset-gulp": "^1.0.0", | ||
"mocha": "^3.5.0" | ||
"eslint": "^7.32.0", | ||
"eslint-config-gulp": "^5.0.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"expect": "^27.3.1", | ||
"mocha": "^8.4.0", | ||
"nyc": "^15.1.0" | ||
}, | ||
"nyc": { | ||
"reporter": [ | ||
"lcov", | ||
"text-summary" | ||
] | ||
}, | ||
"prettier": { | ||
"singleQuote": true | ||
}, | ||
"keywords": [ | ||
@@ -39,0 +44,0 @@ "registry", |
103
README.md
<p align="center"> | ||
<a href="http://gulpjs.com"> | ||
<a href="https://gulpjs.com"> | ||
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png"> | ||
@@ -9,3 +9,3 @@ </a> | ||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url] | ||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url] | ||
@@ -29,8 +29,8 @@ Default registry in gulp 4. | ||
Constructor for the default registry. Inherit from this constructor to build custom registries. | ||
Constructor for the default registry. Inherit from this constructor to build custom registries. | ||
### init(taker) | ||
No-op method that receives the undertaker instance. Useful to set pre-defined tasks using the | ||
`undertaker.task(taskName, fn)` method. Custom registries can override this method when inheriting | ||
No-op method that receives the undertaker instance. Useful to set pre-defined tasks using the | ||
`undertaker.task(taskName, fn)` method. Custom registries can override this method when inheriting | ||
from this default registry. | ||
@@ -40,10 +40,10 @@ | ||
Returns the task with that name or undefined if no task is registered with that name. Useful for custom | ||
task storage. Custom registries can override this method when inheriting from this default registry. | ||
Returns the task with that name or undefined if no task is registered with that name. Useful for custom | ||
task storage. Custom registries can override this method when inheriting from this default registry. | ||
### set(taskName, fn) => [Function] | ||
Adds a task to the registry. If `set` modifies a task, it should return the new task so Undertaker can | ||
properly maintain metadata for the task. Useful for adding custom behavior to every task as it is | ||
registered in the system. Custom registries can override this method when inheriting from this default | ||
Adds a task to the registry. If `set` modifies a task, it should return the new task so Undertaker can | ||
properly maintain metadata for the task. Useful for adding custom behavior to every task as it is | ||
registered in the system. Custom registries can override this method when inheriting from this default | ||
registry. | ||
@@ -53,4 +53,4 @@ | ||
Returns an object listing all tasks in the registry. Necessary to override if the `get` method is overridden | ||
for custom task storage. Custom registries can override this when when inheriting from this default | ||
Returns an object listing all tasks in the registry. Necessary to override if the `get` method is overridden | ||
for custom task storage. Custom registries can override this when when inheriting from this default | ||
registry. | ||
@@ -67,3 +67,3 @@ | ||
- `get(taskName)`: returns the task with that name | ||
or `undefined` if no task is registered with that name. | ||
or `undefined` if no task is registered with that name. | ||
- `set(taskName, fn)`: add task to the registry. If `set` modifies a task, it should return the new task. | ||
@@ -83,3 +83,3 @@ - `tasks()`: returns an object listing all tasks in the registry. | ||
function MyRegistry(){ | ||
function MyRegistry() { | ||
DefaultRegistry.call(this); | ||
@@ -108,3 +108,3 @@ } | ||
function CommonRegistry(opts){ | ||
function CommonRegistry(opts) { | ||
DefaultRegistry.call(this); | ||
@@ -119,14 +119,16 @@ | ||
CommonRegistry.prototype.init = function(takerInst){ | ||
CommonRegistry.prototype.init = function (takerInst) { | ||
var buildDir = this.buildDir; | ||
var exists = fs.existsSync(buildDir); | ||
if(exists){ | ||
throw new Error('Cannot initialize common tasks. ' + buildDir + ' directory exists.'); | ||
if (exists) { | ||
throw new Error( | ||
'Cannot initialize common tasks. ' + buildDir + ' directory exists.' | ||
); | ||
} | ||
takerInst.task('clean', function(){ | ||
takerInst.task('clean', function () { | ||
return del([buildDir]); | ||
}); | ||
} | ||
}; | ||
@@ -137,2 +139,3 @@ module.exports = CommonRegistry; | ||
Then to use it in a project: | ||
```javascript | ||
@@ -144,6 +147,9 @@ var Undertaker = require('undertaker'); | ||
taker.task('build', taker.series('clean', function build(cb) { | ||
// do things | ||
cb(); | ||
})); | ||
taker.task( | ||
'build', | ||
taker.series('clean', function build(cb) { | ||
// do things | ||
cb(); | ||
}) | ||
); | ||
``` | ||
@@ -155,3 +161,3 @@ | ||
For example if you wanted all tasks to share some data, you can use a custom registry | ||
For example if you wanted all tasks to share some data, you can use a custom registry | ||
to bind them to that data. Be sure to return the altered task, as per the description | ||
@@ -170,3 +176,3 @@ of registry methods above: | ||
function ConfigRegistry(config){ | ||
function ConfigRegistry(config) { | ||
DefaultRegistry.call(this); | ||
@@ -180,3 +186,3 @@ this.config = config; | ||
// The `DefaultRegistry` uses `this._tasks` for storage. | ||
var task = this._tasks[name] = fn.bind(this.config); | ||
var task = (this._tasks[name] = fn.bind(this.config)); | ||
return task; | ||
@@ -192,13 +198,18 @@ }; | ||
// `ConfigRegistry.prototype.set` which will bind them to the config object. | ||
taker.registry(new ConfigRegistry({ | ||
src: './src', | ||
build: './build', | ||
bindTo: '0.0.0.0:8888' | ||
})); | ||
taker.registry( | ||
new ConfigRegistry({ | ||
src: './src', | ||
build: './build', | ||
bindTo: '0.0.0.0:8888', | ||
}) | ||
); | ||
taker.task('default', taker.series('clean', 'build', 'serve', function(cb) { | ||
console.log('Server bind to ' + this.bindTo); | ||
console.log('Serving' + this.build); | ||
cb(); | ||
})); | ||
taker.task( | ||
'default', | ||
taker.series('clean', 'build', 'serve', function (cb) { | ||
console.log('Server bind to ' + this.bindTo); | ||
console.log('Serving' + this.build); | ||
cb(); | ||
}) | ||
); | ||
``` | ||
@@ -210,16 +221,12 @@ | ||
[downloads-image]: http://img.shields.io/npm/dm/undertaker-registry.svg | ||
<!-- prettier-ignore-start --> | ||
[downloads-image]: https://img.shields.io/npm/dm/undertaker-registry.svg?style=flat-square | ||
[npm-url]: https://npmjs.org/package/undertaker-registry | ||
[npm-image]: http://img.shields.io/npm/v/undertaker-registry.svg | ||
[npm-image]: https://img.shields.io/npm/v/undertaker-registry.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/gulpjs/undertaker-registry | ||
[travis-image]: http://img.shields.io/travis/gulpjs/undertaker-registry.svg | ||
[ci-url]: https://github.com/gulpjs/undertaker-registry/actions?query=workflow:dev | ||
[ci-image]: https://img.shields.io/github/workflow/status/gulpjs/undertaker-registry/dev?style=flat-square | ||
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/undertaker-registry | ||
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/undertaker-registry.svg?label=appveyor | ||
[coveralls-url]: https://coveralls.io/r/gulpjs/undertaker-registry | ||
[coveralls-image]: http://img.shields.io/coveralls/gulpjs/undertaker-registry/master.svg | ||
[gitter-url]: https://gitter.im/gulpjs/gulp | ||
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg | ||
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/undertaker-registry/master.svg?style=flat-square | ||
<!-- prettier-ignore-end --> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6
23
218
9072