node-gulp-4.0.2+~cs38.20.35/ 0000775 0000000 0000000 00000000000 14156670073 0015040 5 ustar 00root root 0000000 0000000 node-gulp-4.0.2+~cs38.20.35/.ci/ 0000775 0000000 0000000 00000000000 14156670073 0015511 5 ustar 00root root 0000000 0000000 node-gulp-4.0.2+~cs38.20.35/.ci/.azure-pipelines-steps.yml 0000664 0000000 0000000 00000002066 14156670073 0022566 0 ustar 00root root 0000000 0000000 steps:
- script: npm i -g npm@$(npm_version)
displayName: Use legacy npm version $(npm_version)
condition: ne(variables['npm_version'], '')
- task: NodeTool@0
inputs:
versionSpec: '$(node_version)'
displayName: Use Node $(node_version)
- script: npm install
displayName: npm install
- script: npm test
displayName: Run tests
- script: npm run coveralls
displayName: Run coveralls
env:
# Pretend to be AppVeyor for now
APPVEYOR: true
APPVEYOR_BUILD_NUMBER: $(Build.BuildNumber)
APPVEYOR_BUILD_ID: $(Agent.OS)_$(node_version)
APPVEYOR_REPO_COMMIT: $(Build.SourceVersion)
APPVEYOR_REPO_BRANCH: $(Build.SourceBranchName)
# Overwrite the AppVeyor Service Name
COVERALLS_SERVICE_NAME: Azure Pipelines
COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN_SECRET)
COVERALLS_PARALLEL: true
CI_PULL_REQUEST: $(System.PullRequest.PullRequestNumber)
- script: npm run azure-pipelines
displayName: Write tests to xml
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/test.xunit'
condition: succeededOrFailed()
node-gulp-4.0.2+~cs38.20.35/.ci/.azure-pipelines.yml 0000664 0000000 0000000 00000004050 14156670073 0021425 0 ustar 00root root 0000000 0000000 trigger:
- master
- releases/*
jobs:
- job: Test_Linux
displayName: Run Tests on Linux
pool:
vmImage: "Ubuntu 16.04"
strategy:
matrix:
Node_v12:
node_version: 12
Node_v10:
node_version: 10
Node_v8:
node_version: 8
Node_v6:
node_version: 6
Node_v4:
node_version: 4
Node_v0_12:
node_version: 0.12
Node_v0_10:
node_version: 0.10
steps:
- template: .azure-pipelines-steps.yml
- job: Test_Windows
displayName: Run Tests on Windows
pool:
vmImage: vs2017-win2016
strategy:
matrix:
Node_v12:
node_version: 12
Node_v10:
node_version: 10
Node_v8:
node_version: 8
Node_v6:
node_version: 6
Node_v4:
node_version: 4
npm_version: 2
Node_v0_12:
node_version: 0.12
npm_version: 2
Node_v0_10:
node_version: 0.10
npm_version: 2
steps:
- template: .azure-pipelines-steps.yml
- job: Test_MacOS
displayName: Run Tests on MacOS
pool:
vmImage: macos-10.13
strategy:
matrix:
Node_v12:
node_version: 12
Node_v10:
node_version: 10
Node_v8:
node_version: 8
Node_v6:
node_version: 6
Node_v4:
node_version: 4
Node_v0_12:
node_version: 0.12
Node_v0_10:
node_version: 0.10
steps:
- template: .azure-pipelines-steps.yml
- job: Notify_Coveralls
displayName: Notify Coveralls that the parallel report is done
pool:
vmImage: "Ubuntu 16.04"
dependsOn:
- Test_Linux
- Test_Windows
- Test_MacOS
steps:
- script: curl -k https://coveralls.io/webhook?repo_token=$COVERALLS_REPO_TOKEN -d "payload[build_num]=$BUILD_NAME&payload[status]=done"
env:
COVERALLS_REPO_TOKEN: $(COVERALLS_REPO_TOKEN_SECRET)
BUILD_NAME: $(Build.BuildNumber)
node-gulp-4.0.2+~cs38.20.35/.editorconfig 0000664 0000000 0000000 00000000326 14156670073 0017516 0 ustar 00root root 0000000 0000000 # http://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
[*.md]
trim_trailing_whitespace = false
node-gulp-4.0.2+~cs38.20.35/.eslintignore 0000664 0000000 0000000 00000000044 14156670073 0017541 0 ustar 00root root 0000000 0000000 test/fixtures/out
test/fixtures/tmp
node-gulp-4.0.2+~cs38.20.35/.eslintrc 0000664 0000000 0000000 00000000030 14156670073 0016655 0 ustar 00root root 0000000 0000000 {
"extends": "gulp"
}
node-gulp-4.0.2+~cs38.20.35/.gitattributes 0000664 0000000 0000000 00000000016 14156670073 0017730 0 ustar 00root root 0000000 0000000 * text eol=lf
node-gulp-4.0.2+~cs38.20.35/.github/ 0000775 0000000 0000000 00000000000 14156670073 0016400 5 ustar 00root root 0000000 0000000 node-gulp-4.0.2+~cs38.20.35/.github/support.yml 0000664 0000000 0000000 00000000142 14156670073 0020634 0 ustar 00root root 0000000 0000000 # Configuration for support-requests - https://github.com/dessant/support-requests
_extends: gulp
node-gulp-4.0.2+~cs38.20.35/.npmrc 0000664 0000000 0000000 00000000023 14156670073 0016153 0 ustar 00root root 0000000 0000000 package-lock=false
node-gulp-4.0.2+~cs38.20.35/.travis.yml 0000664 0000000 0000000 00000000213 14156670073 0017145 0 ustar 00root root 0000000 0000000 sudo: false
language: node_js
node_js:
- '12'
- '10'
- '8'
- '6'
- '4'
- '0.12'
- '0.10'
after_script:
- npm run coveralls
node-gulp-4.0.2+~cs38.20.35/LICENSE 0000664 0000000 0000000 00000002142 14156670073 0016044 0 ustar 00root root 0000000 0000000 The MIT License (MIT)
Copyright (c) 2014 Blaine Bublitz, Eric Schoffstall and other contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
node-gulp-4.0.2+~cs38.20.35/README.md 0000664 0000000 0000000 00000024734 14156670073 0016331 0 ustar 00root root 0000000 0000000
# undertaker
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Azure Pipelines Build Status][azure-pipelines-image]][azure-pipelines-url] [![Travis 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]
## Usage
```js
var fs = require('fs');
var Undertaker = require('undertaker');
var taker = new Undertaker();
taker.task('task1', function(cb){
// do things
cb(); // when everything is done
});
taker.task('task2', function(){
return fs.createReadStream('./myFile.js')
.pipe(fs.createWriteStream('./myFile.copy.js'));
});
taker.task('task3', function(){
return new Promise(function(resolve, reject){
// do things
resolve(); // when everything is done
});
});
taker.task('combined', taker.series('task1', 'task2'));
taker.task('all', taker.parallel('combined', 'task3'));
```
## API
__Task functions can be completed in any of the ways supported by
[`async-done`][async-resolution]__
### `new Undertaker([registryInstance])`
The constructor is used to create a new instance of `Undertaker`. Each instance of
`Undertaker` gets its own instance of a registry. By default, the registry is an
instance of [`undertaker-registry`][undertaker-registry]
but it can be an instance of any other registry that follows the [Custom Registries API][custom-registries].
To use a custom registry, pass a custom registry instance (`new CustomRegistry([options])`) when
instantiating a new `Undertaker` instance. This will use the custom registry instance for that `Undertaker` instance.
### `task([taskName,] fn)`
Both a `getter` and `setter` for tasks.
If a string (`taskName`) is given as the only argument, it behaves as a `getter`
and returns the wrapped task (not the original function). The wrapped task has a `unwrap`
method that will return the original function.
If a function (`fn`) and optionally a string (`taskName`) is given, it behaves as
a `setter` and will register the task by the `taskName`. If `taskName` is not
specified, the `name` or `displayName` property of the function is used as the `taskName`.
Will throw if:
* As a `getter`: `taskName` is missing or not a string.
* As a `setter`: `taskName` is missing and `fn` is anonymous.
* As a `setter`: `fn` is missing or not a function.
### `series(taskName || fn...)`
Takes a variable amount of strings (`taskName`) and/or functions (`fn`) and
returns a function of the composed tasks or functions. Any `taskNames` are
retrieved from the registry using the `get` method.
When the returned function is executed, the tasks or functions will be executed
in series, each waiting for the prior to finish. If an error occurs, execution
will stop.
### `parallel(taskName || fn...)`
Takes a variable amount of strings (`taskName`) and/or functions (`fn`) and
returns a function of the composed tasks or functions. Any `taskNames` are
retrieved from the registry using the `get` method.
When the returned function is executed, the tasks or functions will be executed
in parallel, all being executed at the same time. If an error occurs, all execution
will complete.
### `registry([registryInstance])`
Optionally takes an instantiated registry object. If no arguments are passed, returns
the current registry object. If an instance of a registry (`customRegistry`) is passed
the tasks from the current registry will be transferred to it and the current registry
will be replaced with the new registry.
The ability to assign new registries will allow you to pre-define/share tasks or add
custom functionality to your registries. See [Custom Registries][custom-registries]
for more information.
### `tree([options])`
Optionally takes an `options` object and returns an object representing the
tree of registered tasks. The object returned is [`archy`][archy]
compatible. Also, each node has a `type` property that can be used to determine if the node is a `task` or `function`.
#### `options`
##### `options.deep`
Whether or not the whole tree should be returned.
Type: `Boolean`
Default: `false`
### `lastRun(task, [precision])`
Takes a string or function (`task`) and returns a timestamp of the last time the task
was run successfully. The time will be the time the task started.
Returns `undefined` if the task has not been run.
If a task errors, the result of `lastRun` will be undefined because the task
should probably be re-run from scratch to get into a good state again.
The timestamp is always given in millisecond but the time resolution can be
rounded using the `precision` parameter. The use case is to be able to compare a build time
to a file time attribute. On node v0.10 or with file system like HFS or FAT,
`fs.stat` time attributes like `mtime` precision is one second.
Assuming `undertakerInst.lastRun('someTask')` returns `1426000001111`,
`undertakerInst.lastRun('someTask', 1000)` returns `1426000001000`.
The default time resolution is `1000` on node v0.10, `0` on node 0.11+ but
it can be overwritten using `UNDERTAKER_TIME_RESOLUTION` environment variable.
## Custom Registries
Custom registries are constructor functions allowing you to pre-define/share tasks
or add custom functionality to your registries.
A registry's prototype should define:
- `init(taker)`: receives the undertaker instance to set pre-defined tasks using the `task(taskName, fn)` method.
- `get(taskName)`: returns the task 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.
- `tasks()`: returns an object listing all tasks in the registry.
You should not call these functions yourself; leave that to Undertaker, so it can
keep its metadata consistent.
The easiest way to create a custom registry is to inherit from [undertaker-registry]:
```js
var util = require('util');
var DefaultRegistry = require('undertaker-registry');
function MyRegistry(){
DefaultRegistry.call(this);
}
util.inherits(MyRegistry, DefaultRegistry);
module.exports = MyRegistry;
```
### Sharing tasks
To share common tasks with all your projects, you can expose an `init` method on the registry
prototype and it will receive the `Undertaker` instance as the only argument. You can then use
`undertaker.task(name, fn)` to register pre-defined tasks.
For example you might want to share a `clean` task:
```js
var fs = require('fs');
var util = require('util');
var DefaultRegistry = require('undertaker-registry');
var del = require('del');
function CommonRegistry(opts){
DefaultRegistry.call(this);
opts = opts || {};
this.buildDir = opts.buildDir || './build';
}
util.inherits(CommonRegistry, DefaultRegistry);
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.');
}
takerInst.task('clean', function(){
return del([buildDir]);
});
}
module.exports = CommonRegistry;
```
Then to use it in a project:
```js
var Undertaker = require('undertaker');
var CommonRegistry = require('myorg-common-tasks');
var taker = new Undertaker(CommonRegistry({ buildDir: '/dist' }));
taker.task('build', taker.series('clean', function build(cb) {
// do things
cb();
}));
```
### Sharing Functionalities
By controlling how tasks are added to the registry, you can decorate them.
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
of registry methods above:
```js
var util = require('util');
var Undertaker = require('undertaker');
var DefaultRegistry = require('undertaker-registry');
// Some task defined somewhere else
var BuildRegistry = require('./build.js');
var ServeRegistry = require('./serve.js');
function ConfigRegistry(config){
DefaultRegistry.call(this);
this.config = config;
}
util.inherits(ConfigRegistry, DefaultRegistry);
ConfigRegistry.prototype.set = function set(name, fn) {
// The `DefaultRegistry` uses `this._tasks` for storage.
var task = this._tasks[name] = fn.bind(this.config);
return task;
};
var taker = new Undertaker();
taker.registry(new BuildRegistry());
taker.registry(new ServeRegistry());
// `taker.registry` will reset each task in the registry with
// `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.task('default', taker.series('clean', 'build', 'serve', function(cb) {
console.log('Server bind to ' + this.bindTo);
console.log('Serving' + this.build);
cb();
}));
```
### In the wild
* [undertaker-registry] - Custom registries probably want to inherit from this.
* [undertaker-forward-reference] - Custom registry supporting forward referenced tasks (similar to gulp 3.x).
* [undertaker-task-metadata] - Proof-of-concept custom registry that attaches metadata to each task.
* [undertaker-common-tasks] - Proof-of-concept custom registry that pre-defines some tasks.
* [alchemist-gulp] - A default set of tasks for building alchemist plugins.
* [gulp-hub] - Custom registry to run tasks in multiple gulpfiles. (In a branch as of this writing)
* [gulp-pipeline] - [RailsRegistry][rails-registry] is an ES2015 class that provides a gulp pipeline replacement for rails applications
## License
MIT
[downloads-image]: https://img.shields.io/npm/dm/undertaker.svg
[npm-url]: https://www.npmjs.com/package/undertaker
[npm-image]: https://img.shields.io/npm/v/undertaker.svg
[azure-pipelines-url]: https://dev.azure.com/gulpjs/gulp/_build/latest?definitionId=$PROJECT_ID&branchName=master
[azure-pipelines-image]: https://dev.azure.com/gulpjs/gulp/_apis/build/status/undertaker?branchName=master
[travis-url]: https://travis-ci.org/gulpjs/undertaker
[travis-image]: https://img.shields.io/travis/gulpjs/undertaker.svg?label=travis-ci
[appveyor-url]: https://ci.appveyor.com/project/gulpjs/undertaker
[appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/undertaker.svg?label=appveyor
[coveralls-url]: https://coveralls.io/r/gulpjs/undertaker
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/undertaker/master.svg
[gitter-url]: https://gitter.im/gulpjs/gulp
[gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg
node-gulp-4.0.2+~cs38.20.35/appveyor.yml 0000664 0000000 0000000 00000001252 14156670073 0017430 0 ustar 00root root 0000000 0000000 # http://www.appveyor.com/docs/appveyor-yml
# http://www.appveyor.com/docs/lang/nodejs-iojs
environment:
matrix:
# node.js
- nodejs_version: "0.10"
- nodejs_version: "0.12"
- nodejs_version: "4"
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "10"
- nodejs_version: "12"
platform:
- x86
- x64
install:
# https://www.appveyor.com/docs/lang/nodejs-iojs/#installing-any-version-of-nodejs-or-iojs
- ps: Update-NodeJsInstallation (Get-NodeJsLatestBuild $env:nodejs_version) $env:PLATFORM
- npm install
test_script:
- node --version
- npm --version
- cmd: npm test
build: off
# build version format
version: "{build}"
node-gulp-4.0.2+~cs38.20.35/index.js 0000664 0000000 0000000 00000002120 14156670073 0016500 0 ustar 00root root 0000000 0000000 'use strict';
var inherits = require('util').inherits;
var EventEmitter = require('events').EventEmitter;
var DefaultRegistry = require('undertaker-registry');
var tree = require('./lib/tree');
var task = require('./lib/task');
var series = require('./lib/series');
var lastRun = require('./lib/last-run');
var parallel = require('./lib/parallel');
var registry = require('./lib/registry');
var _getTask = require('./lib/get-task');
var _setTask = require('./lib/set-task');
function Undertaker(customRegistry) {
EventEmitter.call(this);
this._registry = new DefaultRegistry();
if (customRegistry) {
this.registry(customRegistry);
}
this._settle = (process.env.UNDERTAKER_SETTLE === 'true');
}
inherits(Undertaker, EventEmitter);
Undertaker.prototype.tree = tree;
Undertaker.prototype.task = task;
Undertaker.prototype.series = series;
Undertaker.prototype.lastRun = lastRun;
Undertaker.prototype.parallel = parallel;
Undertaker.prototype.registry = registry;
Undertaker.prototype._getTask = _getTask;
Undertaker.prototype._setTask = _setTask;
module.exports = Undertaker;
node-gulp-4.0.2+~cs38.20.35/lib/ 0000775 0000000 0000000 00000000000 14156670073 0015606 5 ustar 00root root 0000000 0000000 node-gulp-4.0.2+~cs38.20.35/lib/get-task.js 0000664 0000000 0000000 00000000140 14156670073 0017656 0 ustar 00root root 0000000 0000000 'use strict';
function get(name) {
return this._registry.get(name);
}
module.exports = get;
node-gulp-4.0.2+~cs38.20.35/lib/helpers/ 0000775 0000000 0000000 00000000000 14156670073 0017250 5 ustar 00root root 0000000 0000000 node-gulp-4.0.2+~cs38.20.35/lib/helpers/buildTree.js 0000664 0000000 0000000 00000001007 14156670073 0021523 0 ustar 00root root 0000000 0000000 'use strict';
var map = require('collection-map');
var metadata = require('./metadata');
function buildTree(tasks) {
return map(tasks, function(task) {
var meta = metadata.get(task);
if (meta) {
return meta.tree;
}
var name = task.displayName || task.name || '';
meta = {
name: name,
tree: {
label: name,
type: 'function',
nodes: [],
},
};
metadata.set(task, meta);
return meta.tree;
});
}
module.exports = buildTree;
node-gulp-4.0.2+~cs38.20.35/lib/helpers/createExtensions.js 0000664 0000000 0000000 00000003201 14156670073 0023125 0 ustar 00root root 0000000 0000000 'use strict';
var captureLastRun = require('last-run').capture;
var releaseLastRun = require('last-run').release;
var metadata = require('./metadata');
var uid = 0;
function Storage(fn) {
var meta = metadata.get(fn);
this.fn = meta.orig || fn;
this.uid = uid++;
this.name = meta.name;
this.branch = meta.branch || false;
this.captureTime = Date.now();
this.startHr = [];
}
Storage.prototype.capture = function() {
captureLastRun(this.fn, this.captureTime);
};
Storage.prototype.release = function() {
releaseLastRun(this.fn);
};
function createExtensions(ee) {
return {
create: function(fn) {
return new Storage(fn);
},
before: function(storage) {
storage.startHr = process.hrtime();
ee.emit('start', {
uid: storage.uid,
name: storage.name,
branch: storage.branch,
time: Date.now(),
});
},
after: function(result, storage) {
if (result && result.state === 'error') {
return this.error(result.value, storage);
}
storage.capture();
ee.emit('stop', {
uid: storage.uid,
name: storage.name,
branch: storage.branch,
duration: process.hrtime(storage.startHr),
time: Date.now(),
});
},
error: function(error, storage) {
if (Array.isArray(error)) {
error = error[0];
}
storage.release();
ee.emit('error', {
uid: storage.uid,
name: storage.name,
branch: storage.branch,
error: error,
duration: process.hrtime(storage.startHr),
time: Date.now(),
});
},
};
}
module.exports = createExtensions;
node-gulp-4.0.2+~cs38.20.35/lib/helpers/metadata.js 0000664 0000000 0000000 00000000206 14156670073 0021364 0 ustar 00root root 0000000 0000000 'use strict';
// WeakMap for storing metadata
var WM = require('es6-weak-map');
var metadata = new WM();
module.exports = metadata;
node-gulp-4.0.2+~cs38.20.35/lib/helpers/normalizeArgs.js 0000664 0000000 0000000 00000002422 14156670073 0022423 0 ustar 00root root 0000000 0000000 'use strict';
var assert = require('assert');
var map = require('arr-map');
var flatten = require('arr-flatten');
var levenshtein = require('fast-levenshtein');
function normalizeArgs(registry, args) {
function getFunction(task) {
if (typeof task === 'function') {
return task;
}
var fn = registry.get(task);
if (!fn) {
var similar = similarTasks(registry, task);
if (similar.length > 0) {
assert(false, 'Task never defined: ' + task + ' - did you mean? ' + similar.join(', '));
} else {
assert(false, 'Task never defined: ' + task);
}
}
return fn;
}
var flattenArgs = flatten(args);
assert(flattenArgs.length, 'One or more tasks should be combined using series or parallel');
return map(flattenArgs, getFunction);
}
function similarTasks(registry, queryTask) {
if (typeof queryTask !== 'string') {
return [];
}
var tasks = registry.tasks();
var similarTasks = [];
for (var task in tasks) {
if (tasks.hasOwnProperty(task)) {
var distance = levenshtein.get(task, queryTask);
var allowedDistance = Math.floor(0.4 * task.length) + 1;
if (distance < allowedDistance) {
similarTasks.push(task);
}
}
}
return similarTasks;
}
module.exports = normalizeArgs;
node-gulp-4.0.2+~cs38.20.35/lib/helpers/validateRegistry.js 0000664 0000000 0000000 00000002224 14156670073 0023130 0 ustar 00root root 0000000 0000000 'use strict';
var assert = require('assert');
function isFunction(fn) {
return typeof fn === 'function';
}
function isConstructor(registry) {
if (!(registry && registry.prototype)) {
return false;
}
var hasProtoGet = isFunction(registry.prototype.get);
var hasProtoSet = isFunction(registry.prototype.set);
var hasProtoInit = isFunction(registry.prototype.init);
var hasProtoTasks = isFunction(registry.prototype.tasks);
if (hasProtoGet || hasProtoSet || hasProtoInit || hasProtoTasks) {
return true;
}
return false;
}
function validateRegistry(registry) {
try {
assert(isFunction(registry.get), 'Custom registry must have `get` function');
assert(isFunction(registry.set), 'Custom registry must have `set` function');
assert(isFunction(registry.init), 'Custom registry must have `init` function');
assert(isFunction(registry.tasks), 'Custom registry must have `tasks` function');
} catch (err) {
if (isConstructor(registry)) {
assert(false, 'Custom registries must be instantiated, but it looks like you passed a constructor');
} else {
throw err;
}
}
}
module.exports = validateRegistry;
node-gulp-4.0.2+~cs38.20.35/lib/last-run.js 0000664 0000000 0000000 00000000743 14156670073 0017715 0 ustar 00root root 0000000 0000000 'use strict';
var retrieveLastRun = require('last-run');
var metadata = require('./helpers/metadata');
function lastRun(task, timeResolution) {
if (timeResolution == null) {
timeResolution = process.env.UNDERTAKER_TIME_RESOLUTION;
}
var fn = task;
if (typeof task === 'string') {
fn = this._getTask(task);
}
var meta = metadata.get(fn);
if (meta) {
fn = meta.orig || fn;
}
return retrieveLastRun(fn, timeResolution);
}
module.exports = lastRun;
node-gulp-4.0.2+~cs38.20.35/lib/parallel.js 0000664 0000000 0000000 00000001326 14156670073 0017742 0 ustar 00root root 0000000 0000000 'use strict';
var bach = require('bach');
var metadata = require('./helpers/metadata');
var buildTree = require('./helpers/buildTree');
var normalizeArgs = require('./helpers/normalizeArgs');
var createExtensions = require('./helpers/createExtensions');
function parallel() {
var create = this._settle ? bach.settleParallel : bach.parallel;
var args = normalizeArgs(this._registry, arguments);
var extensions = createExtensions(this);
var fn = create(args, extensions);
var name = '';
metadata.set(fn, {
name: name,
branch: true,
tree: {
label: name,
type: 'function',
branch: true,
nodes: buildTree(args),
},
});
return fn;
}
module.exports = parallel;
node-gulp-4.0.2+~cs38.20.35/lib/registry.js 0000664 0000000 0000000 00000000732 14156670073 0020016 0 ustar 00root root 0000000 0000000 'use strict';
var reduce = require('object.reduce');
var validateRegistry = require('./helpers/validateRegistry');
function setTasks(inst, task, name) {
inst.set(name, task);
return inst;
}
function registry(newRegistry) {
if (!newRegistry) {
return this._registry;
}
validateRegistry(newRegistry);
var tasks = this._registry.tasks();
this._registry = reduce(tasks, setTasks, newRegistry);
this._registry.init(this);
}
module.exports = registry;
node-gulp-4.0.2+~cs38.20.35/lib/series.js 0000664 0000000 0000000 00000001314 14156670073 0017435 0 ustar 00root root 0000000 0000000 'use strict';
var bach = require('bach');
var metadata = require('./helpers/metadata');
var buildTree = require('./helpers/buildTree');
var normalizeArgs = require('./helpers/normalizeArgs');
var createExtensions = require('./helpers/createExtensions');
function series() {
var create = this._settle ? bach.settleSeries : bach.series;
var args = normalizeArgs(this._registry, arguments);
var extensions = createExtensions(this);
var fn = create(args, extensions);
var name = '';
metadata.set(fn, {
name: name,
branch: true,
tree: {
label: name,
type: 'function',
branch: true,
nodes: buildTree(args),
},
});
return fn;
}
module.exports = series;
node-gulp-4.0.2+~cs38.20.35/lib/set-task.js 0000664 0000000 0000000 00000001465 14156670073 0017705 0 ustar 00root root 0000000 0000000 'use strict';
var assert = require('assert');
var metadata = require('./helpers/metadata');
function set(name, fn) {
assert(name, 'Task name must be specified');
assert(typeof name === 'string', 'Task name must be a string');
assert(typeof fn === 'function', 'Task function must be specified');
function taskWrapper() {
return fn.apply(this, arguments);
}
function unwrap() {
return fn;
}
taskWrapper.unwrap = unwrap;
taskWrapper.displayName = name;
var meta = metadata.get(fn) || {};
var nodes = [];
if (meta.branch) {
nodes.push(meta.tree);
}
var task = this._registry.set(name, taskWrapper) || taskWrapper;
metadata.set(task, {
name: name,
orig: fn,
tree: {
label: name,
type: 'task',
nodes: nodes,
},
});
}
module.exports = set;
node-gulp-4.0.2+~cs38.20.35/lib/task.js 0000664 0000000 0000000 00000000356 14156670073 0017112 0 ustar 00root root 0000000 0000000 'use strict';
function task(name, fn) {
if (typeof name === 'function') {
fn = name;
name = fn.displayName || fn.name;
}
if (!fn) {
return this._getTask(name);
}
this._setTask(name, fn);
}
module.exports = task;
node-gulp-4.0.2+~cs38.20.35/lib/tree.js 0000664 0000000 0000000 00000000770 14156670073 0017107 0 ustar 00root root 0000000 0000000 'use strict';
var defaults = require('object.defaults');
var map = require('collection-map');
var metadata = require('./helpers/metadata');
function tree(opts) {
opts = defaults(opts || {}, {
deep: false,
});
var tasks = this._registry.tasks();
var nodes = map(tasks, function(task) {
var meta = metadata.get(task);
if (opts.deep) {
return meta.tree;
}
return meta.tree.label;
});
return {
label: 'Tasks',
nodes: nodes,
};
}
module.exports = tree;
node-gulp-4.0.2+~cs38.20.35/package.json 0000664 0000000 0000000 00000003074 14156670073 0017332 0 ustar 00root root 0000000 0000000 {
"name": "undertaker",
"version": "1.3.0",
"description": "Task registry that allows composition through series/parallel methods.",
"author": "Gulp Team (https://gulpjs.com/)",
"contributors": [
"Blaine Bublitz ",
"Damien Lebrun "
],
"repository": "gulpjs/undertaker",
"license": "MIT",
"engines": {
"node": ">= 0.10"
},
"main": "index.js",
"files": [
"LICENSE",
"index.js",
"lib"
],
"scripts": {
"lint": "eslint .",
"pretest": "npm run lint",
"test": "nyc mocha --async-only",
"azure-pipelines": "nyc mocha --async-only --reporter xunit -O output=test.xunit",
"coveralls": "nyc report --reporter=text-lcov | coveralls"
},
"dependencies": {
"arr-flatten": "^1.0.1",
"arr-map": "^2.0.0",
"bach": "^1.0.0",
"collection-map": "^1.0.0",
"es6-weak-map": "^2.0.1",
"last-run": "^1.1.0",
"object.defaults": "^1.0.0",
"object.reduce": "^1.0.0",
"undertaker-registry": "^1.0.0",
"fast-levenshtein": "^1.0.0"
},
"devDependencies": {
"async-once": "^1.0.0",
"coveralls": "github:phated/node-coveralls#2.x",
"del": "^2.0.2",
"eslint": "^2.13.1",
"eslint-config-gulp": "^3.0.1",
"expect": "^1.20.2",
"gulp-jshint": "^1.8.4",
"mocha": "^3.0.0",
"nyc": "^10.3.2",
"once": "^1.3.1",
"through2": "^2.0.0",
"undertaker-common-tasks": "^1.0.0",
"undertaker-task-metadata": "^1.0.0",
"vinyl-fs": "^2.2.0"
},
"keywords": [
"registry",
"runner",
"task"
]
}
node-gulp-4.0.2+~cs38.20.35/test/ 0000775 0000000 0000000 00000000000 14156670073 0016017 5 ustar 00root root 0000000 0000000 node-gulp-4.0.2+~cs38.20.35/test/.eslintrc 0000664 0000000 0000000 00000000035 14156670073 0017641 0 ustar 00root root 0000000 0000000 {
"extends": "gulp/test"
}
node-gulp-4.0.2+~cs38.20.35/test/fixtures/ 0000775 0000000 0000000 00000000000 14156670073 0017670 5 ustar 00root root 0000000 0000000 node-gulp-4.0.2+~cs38.20.35/test/fixtures/taskTree/ 0000775 0000000 0000000 00000000000 14156670073 0021452 5 ustar 00root root 0000000 0000000 node-gulp-4.0.2+~cs38.20.35/test/fixtures/taskTree/aliasNested.js 0000664 0000000 0000000 00000003566 14156670073 0024256 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = {
label: 'Tasks',
nodes: [
{
label: 'noop',
type: 'task',
nodes: [],
},
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
{
label: 'fn3',
type: 'task',
nodes: [],
},
{
label: 'ser',
type: 'task',
nodes: [
{
label: '',
type: 'function',
branch: true,
nodes: [
{
label: 'noop',
type: 'function',
nodes: [],
},
{
label: '',
type: 'function',
nodes: [],
},
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
{
label: 'fn3',
type: 'task',
nodes: [],
},
],
},
],
},
{
label: 'par',
type: 'task',
nodes: [
{
label: '',
type: 'function',
branch: true,
nodes: [
{
label: 'noop',
type: 'function',
nodes: [],
},
{
label: '',
type: 'function',
nodes: [],
},
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
{
label: 'fn3',
type: 'task',
nodes: [],
},
],
},
],
},
],
};
node-gulp-4.0.2+~cs38.20.35/test/fixtures/taskTree/aliasSimple.js 0000664 0000000 0000000 00000000646 14156670073 0024261 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = {
label: 'Tasks',
nodes: [
{
label: 'noop',
type: 'task',
nodes: [],
},
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
{
label: 'fn3',
type: 'task',
nodes: [],
},
{
label: 'fn4',
type: 'task',
nodes: [],
},
],
};
node-gulp-4.0.2+~cs38.20.35/test/fixtures/taskTree/doubleLevel.js 0000664 0000000 0000000 00000001202 14156670073 0024245 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = {
label: 'Tasks',
nodes: [
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
{
label: 'fn3',
type: 'task',
nodes: [
{
label: '',
type: 'function',
branch: true,
nodes: [
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
],
},
],
},
],
};
node-gulp-4.0.2+~cs38.20.35/test/fixtures/taskTree/simple.js 0000664 0000000 0000000 00000000304 14156670073 0023276 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = {
label: 'Tasks',
nodes: [
'test1',
'test2',
'test3',
'error',
'ser',
'par',
'serpar',
'serpar2',
'',
],
};
node-gulp-4.0.2+~cs38.20.35/test/fixtures/taskTree/singleLevel.js 0000664 0000000 0000000 00000000323 14156670073 0024257 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = {
label: 'Tasks',
nodes: [
{
label: 'fn1',
type: 'task',
nodes: [],
},
{
label: 'fn2',
type: 'task',
nodes: [],
},
],
};
node-gulp-4.0.2+~cs38.20.35/test/fixtures/taskTree/tripleLevel.js 0000664 0000000 0000000 00000004622 14156670073 0024303 0 ustar 00root root 0000000 0000000 'use strict';
module.exports = {
label: 'Tasks',
nodes: [
{
label: 'fn1',
type: 'task',
nodes: [
{
label: '',
type: 'function',
branch: true,
nodes: [
{
label: '',
type: 'function',
nodes: [],
},
{
label: 'noop',
type: 'function',
nodes: [],
},
],
},
],
},
{
label: 'fn2',
type: 'task',
nodes: [
{
label: '',
type: 'function',
branch: true,
nodes: [
{
label: '',
type: 'function',
nodes: [],
},
{
label: 'noop',
type: 'function',
nodes: [],
},
],
},
],
},
{
label: 'fn3',
type: 'task',
nodes: [
{
label: '',
type: 'function',
branch: true,
nodes: [
{
label: 'fn1',
type: 'task',
nodes: [
{
label: '',
type: 'function',
branch: true,
nodes: [
{
label: '',
type: 'function',
nodes: [],
},
{
label: 'noop',
type: 'function',
nodes: [],
},
],
},
],
},
{
label: 'fn2',
type: 'task',
nodes: [
{
label: '',
type: 'function',
branch: true,
nodes: [
{
label: '',
type: 'function',
nodes: [],
},
{
label: 'noop',
type: 'function',
nodes: [],
},
],
},
],
},
],
},
],
},
],
};
node-gulp-4.0.2+~cs38.20.35/test/fixtures/test.js 0000664 0000000 0000000 00000000110 14156670073 0021175 0 ustar 00root root 0000000 0000000 'use strict';
function helloWorld() {
}
module.exports = helloWorld;
node-gulp-4.0.2+~cs38.20.35/test/fixtures/testMore.js 0000664 0000000 0000000 00000000110 14156670073 0022020 0 ustar 00root root 0000000 0000000 'use strict';
function helloWorld() {
}
module.exports = helloWorld;
node-gulp-4.0.2+~cs38.20.35/test/integration.js 0000664 0000000 0000000 00000007705 14156670073 0020711 0 ustar 00root root 0000000 0000000 'use strict';
var expect = require('expect');
var os = require('os');
var fs = require('fs');
var path = require('path');
var vinyl = require('vinyl-fs');
var jshint = require('gulp-jshint');
var spawn = require('child_process').spawn;
var once = require('once');
var aOnce = require('async-once');
var del = require('del');
var through = require('through2');
var Undertaker = require('../');
var isWindows = (os.platform() === 'win32');
function cleanup() {
return del([
path.join(__dirname, './fixtures/out/'),
path.join(__dirname, './fixtures/tmp/'),
]);
}
function noop() { }
describe('integrations', function() {
var taker;
beforeEach(function(done) {
taker = new Undertaker();
done();
});
beforeEach(cleanup);
afterEach(cleanup);
it('should handle vinyl streams', function(done) {
taker.task('test', function() {
return vinyl.src('./fixtures/test.js', { cwd: __dirname })
.pipe(vinyl.dest('./fixtures/out', { cwd: __dirname }));
});
taker.parallel('test')(done);
});
it('should exhaust vinyl streams', function(done) {
taker.task('test', function() {
return vinyl.src('./fixtures/test.js', { cwd: __dirname });
});
taker.parallel('test')(done);
});
it('should lints all piped files', function(done) {
taker.task('test', function() {
return vinyl.src('./fixtures/test.js', { cwd: __dirname })
.pipe(jshint());
});
taker.parallel('test')(done);
});
it('should handle a child process return', function(done) {
taker.task('test', function() {
if (isWindows) {
return spawn('cmd', ['/c', 'dir']).on('error', noop);
}
return spawn('ls', ['-lh', __dirname]);
});
taker.parallel('test')(done);
});
it('should run dependencies once', function(done) {
var count = 0;
taker.task('clean', once(function() {
count++;
return del(['./fixtures/some-build.txt'], { cwd: __dirname });
}));
taker.task('build-this', taker.series('clean', function(cb) {
cb();
}));
taker.task('build-that', taker.series('clean', function(cb) {
cb();
}));
taker.task('build', taker.series(
'clean',
taker.parallel(['build-this', 'build-that'])
));
taker.parallel('build')(function(err) {
expect(count).toEqual(1);
done(err);
});
});
it('should run dependencies once', function(done) {
var count = 0;
taker.task('clean', aOnce(function(cb) {
cb();
count++;
del(['./fixtures/some-build.txt'], { cwd: __dirname }, cb);
}));
taker.task('build-this', taker.series('clean', function(cb) {
cb();
}));
taker.task('build-that', taker.series('clean', function(cb) {
cb();
}));
taker.task('build', taker.series(
'clean',
taker.parallel(['build-this', 'build-that'])
));
taker.parallel('build')(function(err) {
expect(count).toEqual(1);
done(err);
});
});
it('can use lastRun with vinyl.src `since` option', function(done) {
this.timeout(5000);
var count = 0;
function setup() {
return vinyl.src('./fixtures/test*.js', { cwd: __dirname })
.pipe(vinyl.dest('./fixtures/tmp', { cwd: __dirname }));
}
function delay(cb) {
setTimeout(cb, 2000);
}
// Some built
taker.task('build', function() {
return vinyl.src('./fixtures/tmp/*.js', { cwd: __dirname })
.pipe(vinyl.dest('./fixtures/out', { cwd: __dirname }));
});
function userEdit(cb) {
fs.appendFile(path.join(__dirname, './fixtures/tmp/testMore.js'), ' ', cb);
}
function countEditedFiles() {
return vinyl.src('./fixtures/tmp/*.js', { cwd: __dirname, since: taker.lastRun('build') })
.pipe(through.obj(function(file, enc, cb) {
count++;
cb();
}));
}
taker.series(setup, delay, 'build', delay, userEdit, countEditedFiles)(function(err) {
expect(count).toEqual(1);
done(err);
});
});
});
node-gulp-4.0.2+~cs38.20.35/test/last-run.js 0000664 0000000 0000000 00000005702 14156670073 0020126 0 ustar 00root root 0000000 0000000 'use strict';
var expect = require('expect');
var Undertaker = require('../');
describe('lastRun', function() {
var taker, test1, test2, error, alias;
var defaultResolution = process.env.UNDERTAKER_TIME_RESOLUTION;
beforeEach(function(done) {
process.env.UNDERTAKER_TIME_RESOLUTION = '0';
taker = new Undertaker();
test1 = function(cb) {
cb();
};
taker.task('test1', test1);
test2 = function(cb) {
cb();
};
test2.displayName = 'test2';
taker.task(test2);
error = function(cb) {
cb(new Error());
};
taker.task('error', error);
alias = test1;
taker.task('alias', alias);
done();
});
afterEach(function(done) {
process.env.UNDERTAKER_TIME_RESOLUTION = defaultResolution;
done();
});
it('should only record time when task has completed', function(done) {
var ts;
var test = function(cb) {
ts = taker.lastRun('test');
cb();
};
taker.task('test', test);
taker.parallel('test')(function(err) {
expect(ts).toEqual(undefined);
done(err);
});
});
it('should record tasks time execution', function(done) {
taker.parallel('test1')(function(err) {
expect(taker.lastRun('test1')).toExist();
expect(taker.lastRun('test1')).toBeLessThanOrEqualTo(Date.now());
expect(taker.lastRun(test2)).toNotExist();
expect(taker.lastRun(function() {})).toNotExist();
expect(taker.lastRun.bind(taker, 'notexists')).toThrow(Error);
done(err);
});
});
it('should record all tasks time execution', function(done) {
taker.parallel('test1', test2)(function(err) {
expect(taker.lastRun('test1')).toExist();
expect(taker.lastRun('test1')).toBeLessThanOrEqualTo(Date.now());
expect(taker.lastRun(test2)).toExist();
expect(taker.lastRun(test2)).toBeLessThanOrEqualTo(Date.now());
done(err);
});
});
it('should record same tasks time execution for a string task and its original', function(done) {
taker.series(test2)(function(err) {
expect(taker.lastRun(test2)).toEqual(taker.lastRun('test2'));
done(err);
});
});
it('should record tasks time execution for an aliased task', function(done) {
taker.series('alias')(function(err) {
expect(taker.lastRun('alias')).toEqual(taker.lastRun('test1'));
done(err);
});
});
it('should give time with 1s resolution', function(done) {
var resolution = 1000; // 1s
var since = Date.now();
var expected = since - (since % resolution);
taker.series('test1')(function() {
expect(taker.lastRun('test1', resolution)).toEqual(expected);
done();
});
});
it('should not record task start time on error', function(done) {
taker.on('error', function() {
// To keep the test from catching the emitted errors
});
taker.series('error')(function(err) {
expect(err).toExist();
expect(taker.lastRun('error')).toNotExist();
done();
});
});
});
node-gulp-4.0.2+~cs38.20.35/test/parallel.js 0000664 0000000 0000000 00000007530 14156670073 0020156 0 ustar 00root root 0000000 0000000 'use strict';
var expect = require('expect');
var Undertaker = require('../');
function fn1(done) {
done(null, 1);
}
function fn2(done) {
setTimeout(function() {
done(null, 2);
}, 500);
}
function fn3(done) {
done(null, 3);
}
function fnError(done) {
done(new Error('An Error Occurred'));
}
describe('parallel', function() {
var taker;
beforeEach(function(done) {
taker = new Undertaker();
taker.task('test1', fn1);
taker.task('test2', fn2);
taker.task('test3', fn3);
taker.task('error', fnError);
done();
});
it('should throw on non-valid tasks combined with valid tasks', function(done) {
function fail() {
taker.parallel('test1', 'test2', 'test3', {});
}
expect(fail).toThrow(/Task never defined:/);
done();
});
it('should throw on tasks array with both valid and non-valid tasks', function(done) {
function fail() {
taker.parallel(['test1', 'test2', 'test3', {}]);
}
expect(fail).toThrow(/Task never defined:/);
done();
});
it('should throw on non-valid task', function(done) {
function fail() {
taker.parallel({});
}
expect(fail).toThrow(/Task never defined:/);
done();
});
it('should throw when no tasks specified', function(done) {
function fail() {
taker.parallel();
}
expect(fail).toThrow(/One or more tasks should be combined using series or parallel/);
done();
});
it('should throw on empty array of registered tasks', function(done) {
function fail() {
taker.parallel([]);
}
expect(fail).toThrow(/One or more tasks should be combined using series or parallel/);
done();
});
it('should take only one array of registered tasks', function(done) {
taker.parallel(['test1', 'test2', 'test3'])(function(err, results) {
expect(results).toEqual([1, 2, 3]);
done(err);
});
});
it('should take all string names', function(done) {
taker.parallel('test1', 'test2', 'test3')(function(err, results) {
expect(results).toEqual([1, 2, 3]);
done(err);
});
});
it('should take all functions', function(done) {
taker.parallel(fn1, fn2, fn3)(function(err, results) {
expect(results).toEqual([1, 2, 3]);
done(err);
});
});
it('should take string names and functions', function(done) {
taker.parallel('test1', fn2, 'test3')(function(err, results) {
expect(results).toEqual([1, 2, 3]);
done(err);
});
});
it('should take nested parallel', function(done) {
var parallel1 = taker.parallel('test1', 'test2', 'test3');
taker.parallel('test1', parallel1, 'test3')(function(err, results) {
expect(results).toEqual([1, [1, 2, 3], 3]);
done(err);
});
});
it('should stop processing on error', function(done) {
taker.on('error', function() {
// To keep the test from catching the emitted errors
});
taker.parallel('test1', 'error', 'test3')(function(err, results) {
expect(err).toBeAn(Error);
expect(results).toEqual([1, undefined, undefined]);
done();
});
});
it('should throw on unregistered task', function(done) {
function unregistered() {
taker.parallel('unregistered');
}
expect(unregistered).toThrow('Task never defined: unregistered');
done();
});
it('should process all functions if settle flag is true', function(done) {
taker.on('error', function() {
// To keep the test from catching the emitted errors
});
taker._settle = true;
taker.parallel(taker.parallel('test1', 'error'), 'test3')(function(err, results) {
expect(err[0][0]).toBeAn(Error);
expect(results).toEqual([3]);
done();
});
});
it('should not register a displayName on the returned function by default', function(done) {
var task = taker.parallel(fn1);
expect(task.displayName).toEqual(undefined);
done();
});
});
node-gulp-4.0.2+~cs38.20.35/test/registry.js 0000664 0000000 0000000 00000014203 14156670073 0020225 0 ustar 00root root 0000000 0000000 'use strict';
var expect = require('expect');
var Undertaker = require('../');
var DefaultRegistry = require('undertaker-registry');
var CommonRegistry = require('undertaker-common-tasks');
var MetadataRegistry = require('undertaker-task-metadata');
function noop() {}
function CustomRegistry() {}
CustomRegistry.prototype.init = noop;
CustomRegistry.prototype.get = noop;
CustomRegistry.prototype.set = noop;
CustomRegistry.prototype.tasks = noop;
function SetNoReturnRegistry() {
this._tasks = {};
}
SetNoReturnRegistry.prototype.init = noop;
SetNoReturnRegistry.prototype.get = function(name) {
return this.tasks[name];
};
SetNoReturnRegistry.prototype.set = function(name, fn) {
this.tasks[name] = fn;
};
SetNoReturnRegistry.prototype.tasks = noop;
function InvalidRegistry() {}
describe('registry', function() {
describe('method', function() {
it('should return the current registry when no arguments are given', function(done) {
var taker = new Undertaker();
expect(taker.registry()).toEqual(taker._registry);
done();
});
it('should set the registry to the given registry instance argument', function(done) {
var taker = new Undertaker();
var customRegistry = new CustomRegistry();
taker.registry(customRegistry);
expect(taker.registry()).toEqual(customRegistry);
done();
});
it('should validate the custom registry instance', function(done) {
var taker = new Undertaker();
var invalid = new InvalidRegistry();
function invalidSet() {
taker.registry(invalid);
}
expect(invalidSet).toThrow('Custom registry must have `get` function');
done();
});
it('should transfer all tasks from old registry to new', function(done) {
var taker = new Undertaker(new CommonRegistry());
var customRegistry = new DefaultRegistry();
taker.registry(customRegistry);
expect(taker.task('clean')).toBeA('function');
expect(taker.task('serve')).toBeA('function');
done();
});
it('allows multiple custom registries to used', function(done) {
var taker = new Undertaker();
taker.registry(new CommonRegistry());
expect(taker.task('clean')).toBeA('function');
expect(taker.task('serve')).toBeA('function');
taker.registry(new MetadataRegistry());
taker.task('context', function(cb) {
expect(this).toEqual({ name: 'context' });
cb();
done();
});
taker.registry(new DefaultRegistry());
expect(taker.task('clean')).toBeA('function');
expect(taker.task('serve')).toBeA('function');
expect(taker.task('context')).toBeA('function');
taker.series('context')();
});
it('throws with a descriptive method when constructor is passed', function(done) {
var taker = new Undertaker();
function ctor() {
taker.registry(CommonRegistry);
}
expect(ctor).toThrow('Custom registries must be instantiated, but it looks like you passed a constructor');
done();
});
it('calls into the init function after tasks are transferred', function(done) {
var taker = new Undertaker(new CommonRegistry());
var ogInit = DefaultRegistry.prototype.init;
DefaultRegistry.prototype.init = function(inst) {
expect(inst).toEqual(taker);
expect(inst.task('clean')).toBeA('function');
expect(inst.task('serve')).toBeA('function');
};
taker.registry(new DefaultRegistry());
DefaultRegistry.prototype.init = ogInit;
done();
});
});
describe('constructor', function() {
it('should take a custom registry on instantiation', function(done) {
var taker = new Undertaker(new CustomRegistry());
expect(taker.registry()).toBeA(CustomRegistry);
expect(taker.registry()).toNotBeA(DefaultRegistry);
done();
});
it('should default to undertaker-registry if not constructed with custom registry', function(done) {
var taker = new Undertaker();
expect(taker.registry()).toBeA(DefaultRegistry);
expect(taker.registry()).toNotBeA(CustomRegistry);
done();
});
it('should take a registry that pre-defines tasks', function(done) {
var taker = new Undertaker(new CommonRegistry());
expect(taker.registry()).toBeA(CommonRegistry);
expect(taker.registry()).toBeA(DefaultRegistry);
expect(taker.task('clean')).toBeA('function');
expect(taker.task('serve')).toBeA('function');
done();
});
it('should throw upon invalid registry', function(done) {
/* eslint no-unused-vars: 0 */
var taker;
function noGet() {
taker = new Undertaker(new InvalidRegistry());
}
expect(noGet).toThrow('Custom registry must have `get` function');
InvalidRegistry.prototype.get = noop;
function noSet() {
taker = new Undertaker(new InvalidRegistry());
}
expect(noSet).toThrow('Custom registry must have `set` function');
InvalidRegistry.prototype.set = noop;
function noInit() {
taker = new Undertaker(new InvalidRegistry());
}
expect(noInit).toThrow('Custom registry must have `init` function');
InvalidRegistry.prototype.init = noop;
function noTasks() {
taker = new Undertaker(new InvalidRegistry());
}
expect(noTasks).toThrow('Custom registry must have `tasks` function');
InvalidRegistry.prototype.tasks = noop;
taker = new Undertaker(new InvalidRegistry());
done();
});
});
it('does not require the `set` method to return a task', function(done) {
var taker = new Undertaker();
taker.registry(new SetNoReturnRegistry());
taker.task('test', noop);
taker.on('start', function(data) {
expect(data.name).toEqual('test');
done();
});
taker.series('test')();
});
it('should fail and offer tasks which are close in name', function(done) {
var taker = new Undertaker(new CommonRegistry());
var customRegistry = new DefaultRegistry();
taker.registry(customRegistry);
function fail() {
taker.series('clear');
}
expect(fail).toThrow(/Task never defined: clear - did you mean\? clean/);
done();
});
});
node-gulp-4.0.2+~cs38.20.35/test/series.js 0000664 0000000 0000000 00000007460 14156670073 0017656 0 ustar 00root root 0000000 0000000 'use strict';
var expect = require('expect');
var Undertaker = require('../');
function fn1(done) {
done(null, 1);
}
function fn2(done) {
setTimeout(function() {
done(null, 2);
}, 500);
}
function fn3(done) {
done(null, 3);
}
function fnError(done) {
done(new Error('An Error Occurred'));
}
describe('series', function() {
var taker;
beforeEach(function(done) {
taker = new Undertaker();
taker.task('test1', fn1);
taker.task('test2', fn2);
taker.task('test3', fn3);
taker.task('error', fnError);
done();
});
it('should throw on non-valid tasks combined with valid tasks', function(done) {
function fail() {
taker.series('test1', 'test2', 'test3', {});
}
expect(fail).toThrow(/Task never defined:/);
done();
});
it('should throw on tasks array with both valid and non-valid tasks', function(done) {
function fail() {
taker.series(['test1', 'test2', 'test3', {}]);
}
expect(fail).toThrow(/Task never defined:/);
done();
});
it('should throw on non-valid task', function(done) {
function fail() {
taker.series({});
}
expect(fail).toThrow(/Task never defined:/);
done();
});
it('should throw when no tasks specified', function(done) {
function fail() {
taker.series();
}
expect(fail).toThrow(/One or more tasks should be combined using series or parallel/);
done();
});
it('should throw on empty array of registered tasks', function(done) {
function fail() {
taker.series([]);
}
expect(fail).toThrow(/One or more tasks should be combined using series or parallel/);
done();
});
it('should take only one array of registered tasks', function(done) {
taker.series(['test1', 'test2', 'test3'])(function(err, results) {
expect(results).toEqual([1, 2, 3]);
done(err);
});
});
it('should take all string names', function(done) {
taker.series('test1', 'test2', 'test3')(function(err, results) {
expect(results).toEqual([1, 2, 3]);
done(err);
});
});
it('should take all functions', function(done) {
taker.series(fn1, fn2, fn3)(function(err, results) {
expect(results).toEqual([1, 2, 3]);
done(err);
});
});
it('should take string names and functions', function(done) {
taker.series('test1', fn2, 'test3')(function(err, results) {
expect(results).toEqual([1, 2, 3]);
done(err);
});
});
it('should take nested series', function(done) {
var series1 = taker.series('test1', 'test2', 'test3');
taker.series('test1', series1, 'test3')(function(err, results) {
expect(results).toEqual([1, [1, 2, 3], 3]);
done(err);
});
});
it('should stop processing on error', function(done) {
taker.on('error', function() {
// To keep the test from catching the emitted errors
});
taker.series('test1', 'error', 'test3')(function(err, results) {
expect(err).toBeAn(Error);
expect(results).toEqual([1, undefined, undefined]);
done();
});
});
it('should throw on unregistered task', function(done) {
function unregistered() {
taker.series('unregistered');
}
expect(unregistered).toThrow('Task never defined: unregistered');
done();
});
it('should process all functions if settle flag is true', function(done) {
taker.on('error', function() {
// To keep the test from catching the emitted errors
});
taker._settle = true;
taker.series(taker.series('test1', 'error'), 'test3')(function(err, results) {
expect(err[0][0]).toBeAn(Error);
expect(results).toEqual([3]);
done();
});
});
it('should not register a displayName on the returned function by default', function(done) {
var task = taker.series(fn1);
expect(task.displayName).toEqual(undefined);
done();
});
});
node-gulp-4.0.2+~cs38.20.35/test/task.js 0000664 0000000 0000000 00000007732 14156670073 0017330 0 ustar 00root root 0000000 0000000 'use strict';
var expect = require('expect');
var Undertaker = require('../');
function noop(done) {
done();
}
var anon = function() {};
describe('task', function() {
var taker;
beforeEach(function(done) {
taker = new Undertaker();
done();
});
it('should register a named function', function(done) {
taker.task(noop);
expect(taker.task('noop').unwrap()).toEqual(noop);
done();
});
it('should register an anonymous function by string name', function(done) {
taker.task('test1', anon);
expect(taker.task('test1').unwrap()).toEqual(anon);
done();
});
it('should register an anonymous function by displayName property', function(done) {
anon.displayName = '';
taker.task(anon);
expect(taker.task('').unwrap()).toEqual(anon);
delete anon.displayName;
done();
});
it('should throw on register an anonymous function without string name', function(done) {
function noName() {
taker.task(function() {});
}
expect(noName).toThrow('Task name must be specified');
done();
});
it('should register a named function by string name', function(done) {
taker.task('test1', noop);
expect(taker.task('test1').unwrap()).toEqual(noop);
done();
});
it('should not get a task that was not registered', function(done) {
expect(taker.task('test1')).toEqual(undefined);
done();
});
it('should get a task that was registered', function(done) {
taker.task('test1', noop);
expect(taker.task('test1').unwrap()).toEqual(noop);
done();
});
it('should get the wrapped task, not original function', function(done) {
var registry = taker.registry();
taker.task('test1', noop);
expect(taker.task('test1').unwrap).toBeA('function');
expect(taker.task('test1')).toEqual(registry.get('test1'));
done();
});
it('provides an `unwrap` method to get the original function', function(done) {
taker.task('test1', noop);
expect(taker.task('test1').unwrap).toBeA('function');
expect(taker.task('test1').unwrap()).toEqual(noop);
done();
});
it('should return a function that was registered in some other way', function(done) {
taker.registry()._tasks.test1 = noop;
expect(taker.task('test1')).toEqual(noop);
done();
});
it('should prefer displayName instead of name when both properties are defined', function(done) {
function fn() {}
fn.displayName = 'test1';
taker.task(fn);
expect(taker.task('test1').unwrap()).toEqual(fn);
done();
});
it('should allow different tasks to refer to the same function', function(done) {
function fn() {}
taker.task('foo', fn);
taker.task('bar', fn);
expect(taker.task('foo').unwrap()).toEqual(taker.task('bar').unwrap());
done();
});
it('should allow using aliased tasks in composite tasks', function(done) {
var count = 0;
function fn(cb) {
count++;
cb();
}
taker.task('foo', fn);
taker.task('bar', fn);
var series = taker.series('foo', 'bar', function(cb) {
expect(count).toEqual(2);
cb();
});
var parallel = taker.parallel('foo', 'bar', function(cb) {
setTimeout(function() {
expect(count).toEqual(4);
cb();
}, 500);
});
taker.series(series, parallel)(done);
});
it('should allow composite tasks tasks to be aliased', function(done) {
var count = 0;
function fn1(cb) {
count += 1;
cb();
}
function fn2(cb) {
count += 2;
cb();
}
taker.task('ser', taker.series(fn1, fn2));
taker.task('foo', taker.task('ser'));
taker.task('par', taker.parallel(fn1, fn2));
taker.task('bar', taker.task('par'));
var series = taker.series('foo', function(cb) {
expect(count).toEqual(3);
cb();
});
var parallel = taker.series('bar', function(cb) {
setTimeout(function() {
expect(count).toEqual(6);
cb();
}, 500);
});
taker.series(series, parallel)(done);
});
});
node-gulp-4.0.2+~cs38.20.35/test/tree.js 0000664 0000000 0000000 00000006315 14156670073 0017321 0 ustar 00root root 0000000 0000000 'use strict';
var expect = require('expect');
var Undertaker = require('../');
var simple = require('./fixtures/taskTree/simple');
var singleLevel = require('./fixtures/taskTree/singleLevel');
var doubleLevel = require('./fixtures/taskTree/doubleLevel');
var tripleLevel = require('./fixtures/taskTree/tripleLevel');
var aliasSimple = require('./fixtures/taskTree/aliasSimple');
var aliasNested = require('./fixtures/taskTree/aliasNested');
function noop(done) {
done();
}
describe('tree', function() {
var taker;
beforeEach(function(done) {
taker = new Undertaker();
done();
});
it('should return a simple tree by default', function(done) {
taker.task('test1', function(cb) {
cb();
});
taker.task('test2', function(cb) {
cb();
});
taker.task('test3', function(cb) {
cb();
});
taker.task('error', function(cb) {
cb();
});
var ser = taker.series('test1', 'test2');
var anon = function(cb) {
cb();
};
anon.displayName = '';
taker.task('ser', taker.series('test1', 'test2'));
taker.task('par', taker.parallel('test1', 'test2', 'test3'));
taker.task('serpar', taker.series('ser', 'par'));
taker.task('serpar2', taker.series(ser, anon));
taker.task(anon);
var tree = taker.tree();
expect(tree).toEqual(simple);
done();
});
it('should form a 1 level tree', function(done) {
taker.task('fn1', function(cb) {
cb();
});
taker.task('fn2', function(cb) {
cb();
});
var tree = taker.tree({ deep: true });
expect(tree).toEqual(singleLevel);
done();
});
it('should form a 2 level nested tree', function(done) {
taker.task('fn1', function(cb) {
cb();
});
taker.task('fn2', function(cb) {
cb();
});
taker.task('fn3', taker.series('fn1', 'fn2'));
var tree = taker.tree({ deep: true });
expect(tree).toEqual(doubleLevel);
done();
});
it('should form a 3 level nested tree', function(done) {
taker.task('fn1', taker.parallel(function(cb) {
cb();
}, noop));
taker.task('fn2', taker.parallel(function(cb) {
cb();
}, noop));
taker.task('fn3', taker.series('fn1', 'fn2'));
var tree = taker.tree({ deep: true });
expect(tree).toEqual(tripleLevel);
done();
});
it('should use the proper labels for aliased tasks (simple)', function(done) {
var anon = function(cb) {
cb();
};
taker.task(noop);
taker.task('fn1', noop);
taker.task('fn2', taker.task('noop'));
taker.task('fn3', anon);
taker.task('fn4', taker.task('fn3'));
var tree = taker.tree({ deep: true });
expect(tree).toEqual(aliasSimple);
done();
});
it('should use the proper labels for aliased tasks (nested)', function(done) {
taker.task(noop);
taker.task('fn1', noop);
taker.task('fn2', taker.task('noop'));
taker.task('fn3', function(cb) {
cb();
});
taker.task('ser', taker.series(noop, function(cb) {
cb();
}, 'fn1', 'fn2', 'fn3'));
taker.task('par', taker.parallel(noop, function(cb) {
cb();
}, 'fn1', 'fn2', 'fn3'));
var tree = taker.tree({ deep: true });
expect(tree).toEqual(aliasNested);
done();
});
});