Skip to content

Instantly share code, notes, and snippets.

@kazu69
Last active September 6, 2015 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazu69/020451222ded7461a7cc to your computer and use it in GitHub Desktop.
Save kazu69/020451222ded7461a7cc to your computer and use it in GitHub Desktop.
gulp v4.0
gulp --tasks-json
[{"label":"<anonymous>","type":"function","nodes":[]},{"label":"one","type":"task","nodes":[]},{"label":"two","type":"task","nodes":[]},{"label":"three","type":"task","nodes":[]},{"label":"parallel","type":"task","nodes":[{"label":"<parallel>","type":"function","nodes":[{"label":"one","type":"task","nodes":[]},{"label":"two","type":"task","nodes":[]},{"label":"three","type":"task","nodes":[]},{"label":"<anonymous>","type":"function","nodes":[]}]}]},{"label":"series","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"three","type":"task","nodes":[]},{"label":"one","type":"task","nodes":[]},{"label":"two","type":"task","nodes":[]},{"label":"<anonymous>","type":"function","nodes":[]}]}]},{"label":"combine","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"one","type":"task","nodes":[]},{"label":"<series>","type":"function","nodes":[{"label":"two","type":"task","nodes":[]},{"label":"<series>","type":"function","nodes":[{"label":"three","type":"task","nodes":[]},{"label":"<anonymous>","type":"function","nodes":[]}]}]}]}]},{"label":"custom","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"<anonymous>","type":"function","nodes":[]},{"label":"<anonymous>","type":"function","nodes":[]}]}]},{"label":"last","type":"task","nodes":[{"label":"<series>","type":"function","nodes":[{"label":"one","type":"task","nodes":[]},{"label":"<anonymous>","type":"function","nodes":[]}]}]}]
var util = require('util');
var gutil = require('gulp-util');
// init(taker)
// get(taskName)
// set(taskName, fn)
// tasks() を持つ moduleをrequireする
var DefaultRegistry = require('undertaker-registry');
function CustomTasksRegistry() {
DefaultRegistry.call(this);
this.set('customTaskName', function() {
gutil.log('done custom task...');
});
}
// DefaultRegistryを継承
util.inherits(CustomTasksRegistry, DefaultRegistry);
module.exports = new CustomTasksRegistry();
gulp --verify
[12:18:30] Verifying plugins in /Users/PROJECT/package.json
[12:18:30] There are no blacklisted plugins in this project
var gulp = require('gulp');
var gutil = require('gulp-util');
gulp.task('one', function() {
gutil.log('task one done!');
return gulp.src('./gulpfile.js')
});
gulp.task('two', function() {
gutil.log('task two done!');
return gulp.src('./gulpfile.js')
});
gulp.task('three', function() {
gutil.log('task three done!');
return gulp.src('./gulpfile.js')
});
gulp.task('parallel', gulp.parallel('one', 'two','three', function() {
// user runSequence
// runSequence(['one', 'two', 'three']);
gutil.log('task parallel after task done!');
}));
var gulp = require('gulp');
var gutil = require('gulp-util');
gulp.task('one', function() {
gutil.log('task one done!');
return gulp.src('./gulpfile.js')
});
gulp.task('two', function() {
gutil.log('task two done!');
return gulp.src('./gulpfile.js')
});
gulp.task('three', function() {
gutil.log('task three done!');
return gulp.src('./gulpfile.js')
});
gulp.task('series', gulp.series('three', 'one', 'two', function() {
// user runSequence
// runSequence('one', 'two', 'three');
gutil.log('task series after task done!');
}));
var gulp = require('gulp');
var gutil = require('gulp-util');
gulp.task('one', function() {
gutil.log('task one done!');
return gulp.src('./gulpfile.js')
});
gulp.task('two', function() {
gutil.log('task two done!');
return gulp.src('./gulpfile.js')
});
gulp.task('three', function() {
gutil.log('task three done!');
return gulp.src('./gulpfile.js')
});
gulp.task('combine', gulp.series('one',
gulp.series('two',
gulp.series('three', function() {
var options = {
deep: true
}
var tree = gulp.tree(options);
gutil.log(tree);
})
)
));
var gulp = require('gulp');
var gutil = require('gulp-util');
gulp.task('one', function() {
gutil.log('task one done!');
return gulp.src('./gulpfile.js')
});
gulp.task('two', function() {
gutil.log('task two done!');
return gulp.src('./gulpfile.js')
});
gulp.task('three', function() {
gutil.log('task three done!');
return gulp.src('./gulpfile.js')
});
gulp.task('series', gulp.series('three', 'one', 'two', function() {
// user runSequence
// runSequence('one', 'two', 'three');
gutil.log('task series after task done!');
}));
var CustomTasksRegistry = require('./custom.js');
gulp.registry(CustomTasksRegistry);
gulp.task('custom', gulp.series('customTaskName', function() {
gutil.log('custom task done');
}));
var gulp = require('gulp');
var gutil = require('gulp-util');
var moment = require('moment');
gulp.task('one', function() {
gutil.log('task one done!');
return gulp.src('./gulpfile.js')
});
gulp.task('two', function() {
gutil.log('task two done!');
return gulp.src('./gulpfile.js')
});
gulp.task('three', function() {
gutil.log('task three done!');
return gulp.src('./gulpfile.js')
});
gulp.task('last', gulp.series('one', function() {
var time = gulp.lastRun('one');
gutil.log(moment(time).format());
}));
npm i gulpjs/gulp-cli#4.0 -g
npm i git://github.com/gulpjs/gulp.git#4.0 -S
gulp -v
[12:07:42] CLI version 0.4.0
[12:07:42] Local version 4.0.0-alpha.1
gulp -h
Usage: gulp [options] tasks
Options:
--help, -h Show this help.
--version, -v Print the global and local gulp versions.
--require Will require a module before running the gulpfile. This is useful for transpilers but also has other applications.
--gulpfile Manually set path of gulpfile. Useful if you have multiple gulpfiles. This will set the CWD to the gulpfile directory as well.
--cwd Manually set the CWD. The search for the gulpfile, as well as the relativity of all requires will be from here.
--verify Will verify plugins referenced in project's package.json against the plugins blacklist.
--tasks, -T Print the task dependency tree for the loaded gulpfile.
--tasks-simple Print a plaintext list of tasks for the loaded gulpfile.
--tasks-json Print the task dependency tree, in JSON format, for the loaded gulpfile.
--color Will force gulp and gulp plugins to display colors, even when no color support is detected.
--no-color Will force gulp and gulp plugins to not display colors, even when color support is detected.
--silent Suppress all gulp logging.
--continue Continue execution of tasks upon failure.
gulp parallel
[13:19:59] Using gulpfile ~ /PROJECT/gulpfile.js
[13:19:59] Starting 'parallel'...
[13:19:59] Starting 'one'...
[13:19:59] Starting 'two'...
[13:19:59] Starting 'three'...
[13:19:59] Starting '<anonymous>'...
[13:19:59] task one done!
[13:19:59] task two done!
[13:19:59] task three done!
[13:19:59] task parallel after task done!
gulp series
[13:25:12] Using gulpfile ~ /PROJECT/gulpfile.js
[13:25:12] Starting 'series'...
[13:25:12] Starting 'three'...
[13:25:12] task three done!
[13:25:12] Finished 'three' after 31 ms
[13:25:12] Starting 'one'...
[13:25:12] task one done!
[13:25:12] Finished 'one' after 6.2 ms
[13:25:12] Starting 'two'...
[13:25:12] task two done!
[13:25:12] Finished 'two' after 2.5 ms
[13:25:12] Starting '<anonymous>'...
[13:25:12] task series after task done!
gulp combine
[13:55:08] Using gulpfile ~ /PROJECT/gulpfile.js
[13:55:08] Starting 'combine'...
[13:55:08] Starting 'one'...
[13:55:08] task one done!
[13:55:08] Finished 'one' after 19 ms
[13:55:08] Starting 'series'...
[13:55:08] Starting 'two'...
[13:55:08] task two done!
[13:55:08] Finished 'two' after 4.61 ms
[13:55:08] Starting 'series'...
[13:55:08] Starting 'three'...
[13:55:08] task three done!
[13:55:08] Finished 'three' after 2.46 ms
[13:55:08] Starting '<anonymous>'...
[13:55:08] [ { label: 'one', type: 'task', nodes: [] },
{ label: 'two', type: 'task', nodes: [] },
{ label: 'three', type: 'task', nodes: [] },
{ label: 'parallel', type: 'task', nodes: [ [Object] ] },
{ label: 'series', type: 'task', nodes: [ [Object] ] },
{ label: 'combine', type: 'task', nodes: [ [Object] ] } ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment