gulp-fncallback
v2.0.2
Published
Callback for streams
Downloads
292
Readme
gulp-fncallback
Install
npm install gulp-fncallback
Usage transformFunction
var less = require('gulp-less');
var callback = require('gulp-fncallback');
gulp.task('less', function () {
gulp.src('./less/**/*.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(callback(function (file, enc, cb) {
console.log(file);
cb();
}))
.pipe(gulp.dest('./public/css'));
});
Usage transformFunction and flushFunction
var less = require('gulp-less');
var callback = require('gulp-fncallback');
gulp.task('less', function () {
gulp.src('./less/**/*.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(callback(function (file, enc, cb) {
console.log(file);
cb();
}, function (callback) {
callback();
}))
.pipe(gulp.dest('./public/css'));
});
Usage transformFunction with error
var less = require('gulp-less');
var callback = require('gulp-fncallback');
gulp.task('less', function () {
gulp.src('./less/**/*.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(callback(function (file, enc, cb) {
console.log(file);
cb('error');
}))
.pipe(gulp.dest('./public/css'));
});
Usage transformFunction with new file
var less = require('gulp-less');
var callback = require('gulp-fncallback');
gulp.task('less', function () {
gulp.src('./less/**/*.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(callback(function (file, enc, cb) {
var newFile = ...
cb(null, newFile);
}))
.pipe(gulp.dest('./public/css'));
});
Usage transformFunction with new file and append old file
var less = require('gulp-less');
var callback = require('gulp-fncallback');
gulp.task('less', function () {
gulp.src('./less/**/*.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(callback(function (file, enc, cb) {
var newFile = ...
cb(null, newFile, true);
}))
.pipe(gulp.dest('./public/css'));
});
Options
once - Run callback once
var less = require('gulp-less');
var callback = require('gulp-fncallback');
gulp.task('less', function () {
gulp.src('./less/**/*.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(callback(function (file, enc, cb) {
console.log(file);
cb();
}, {
once: true
}))
.pipe(gulp.dest('./public/css'));
});