API - REPL - instances - task params - async composers
-
gulp what? If you don't know gulp go here first
-
Open that
gulpfileand change this line
var gulp = require('gulp');with
var gulp = require('gulp-runtime').create();After that just run the gulpfile with node directly from the command line
node gulpfile.js --tasks default watch serveIf no arguments are given the default task will run instead (as gulp does).
- What about the CLI?
Add an alias to your .bashrc, .zshrc
rulp='node gulpfile.js'The module comes with the same gulp API methods we know and love
gulp.src - gulp.dest - gulp.task - gulp.watch
and 4 more
gulp.start - gulp.stack - gulp.series - gulp.parallel
gulp.src, gulp.dest, gulp.watch and gulp.task behave the same as described in the gulp API documentation.
In addition gulp.task can also define tasks using :parameters.
Example:
var gulp = require('gulp-runtime').create();
gulp.task('build:mode', function (done) {
console.log(this.params.mode);
// do async things
done(); // or return a stream, promise or RxJS observable
});You could also use a regular expression right after :mode
var gulp = require('gulp-runtime').create();
gulp.task('build:mode(-dev|-prod)', function (done){
// do async things
done(); // or return a stream, promise or RxJS observable
});What? Regular expressions?
You don't generally need to care about that, but if you do: the module used for this is parth.
function start(tasks...)Run any number of tasks... given. Tasks can be either a string, that matches one of the tasks registered with or without its parameters, or a function.
Example:
var gulp = require('gulp-runtime').create();
function build(done){
done(); // or do async things
}
gulp.task('thing', function (done){
setTimeout(done, 100);
});
gulp.start(build, 'thing');function start(array tasks, args...)If the first argument is an array its taken as the tasks to run and the rest of arguments as the arguments to pass to the tasks to run.
var gulp = require('gulp-runtime').create();
function build(done, a, b){
done(); // or do async things
}
gulp.task('thing', function (done, a, b){
setTimeout(done, 100);
});
gulp.task('build thing', function (done, a, b){
gulp.start([build, 'thing'], a, b, done);
// done will be called when all of the tasks have ended or there is an error
});
gulp.task('default', function () {
gulp.start('build things', 'a', 'b');
});