On Github eamodeorubio / gulpifyme
By Enrique Amodeo / @eamodeorubio
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.0 Generic Licensegulp.task('task-A', function () { // Do A here! }; gulp.task('task-B', function() { // Do B here! }); gulp.task('task-C', ['task-B'], function() { // Do C here, but wait for B to complete! }); gulp.task('main', ['task-A', 'task-C']);
gulp.task('task-A', function () { return iPromiseIWillDoA(); }; gulp.task('task-B', function(cb) { // Do B if(everythingIsOk()) { return cb(); } cb('Error!'); }); gulp.task('task-C', ['task-B'], function() { return streamOfCoolThingsForC(); });
gulp.task('cool-build', function () { return gulp.src(['src/**/*.js', 'extra/**/*.js']); };
gulp.task('cool-build', function () { return gulp.src(['src/**/*.js', 'extra/**/*.js']) .pipe(coolify()) .pipe(fastify({ compileToC: true })); };
gulp.task('cool-build', function () { return gulp.src(['src/**/*.js', 'extra/**/*.js']) .pipe(coolify()) .pipe(fastify({ compileToC: true })) .pipe(gulp.dest('output/dir/')); };
$> npm install --save-dev gulp-concat $> npm install --save-dev gulp-clean $> npm install --save-dev gulp-less $> npm install --save-dev gulp-bless $> npm install --save-dev gulp-minimify-css $> npm install --save-dev gulp-jshint $> npm install --save-dev gulp-csslint $> npm install --save-dev gulp-mocha $> npm install --save-dev gulp-watch $> npm install --save-dev gulp-cached $> npm install --save-dev gulp-streamify $> npm install --save-dev gulp-uglify $> npm install --save-dev gulp-imagemin
var through = require('through2'), PluginError = require('gulp-util').PluginError; module.exports = function(opts) { return through.obj(function(file, enc, callback) { if (file.isBuffer()) { // Process file, contents are a buffer } else if (file.isStream()) { // Process file, contents are in a stream } if(someError) { this.emit('error', new PluginError(myPluginName, someError)); } else { this.push(file); } callback(); }); };
gulp.task('build:js', ['clean:js'], function () { return browserify({ entries: './main', noParse: ['jquery'], basedir: APP_SRC_DIR }).exclude('jquery') .bundle() // Up to here is normal browserify stuff! .pipe(source(require('./package.json').name + '.min.js')) // From here we have a Vinyl File stream .pipe(streamify(uglify({ preserveComments: 'some' }))) .pipe(gulp.dest(OUTPUT_DIR + 'js')); });
var karma = require('karma'), karmaConfig = require('./karma.conf.js'); gulp.task('karma', ['dist'], function (cb) { karma.server.start(karmaConfig, cb); });
gulp.task('lint', function () { return gulp .src(['test/**/*.js', 'lib/**/*.js']) .pipe(cache(taskId)) .pipe(jshint(config)) .pipe(jshint.reporter('default')); }); gulp.watch(['test/**/*.js', 'lib/**/*.js'], ['lint']);
gulp.task('lint', function () { return gulp .src(['test/**/*.js', 'lib/**/*.js']) .pipe(cache(taskId)) .pipe(jshint(config)) .pipe(jshint.reporter('default')) .pipe(jshint.reporter('fail')); }); gulp.watch(['test/**/*.js', 'lib/**/*.js'], ['lint']);
gulp.task('lint', function () { return gulp .src(['test/**/*.js', 'lib/**/*.js']) .pipe(cache(taskId)) .pipe(jshint(config)) .pipe(jshint.reporter('default')) .pipe(plumber({ errorHandler: function() { this.emit('end'); } })) .pipe(jshint.reporter('fail')); }); gulp.watch(['test/**/*.js', 'lib/**/*.js'], ['lint']);
function makeLint() { return gulp.src(['test/**/*.js', 'lib/**/*.js']) .pipe(cache(taskId)) .pipe(jshint(config)) .pipe(jshint.reporter('default')); } gulp.task('lint', function () { return makeLint(); }); gulp.task('ci', function() { return makeLint().on('error', function() { process.exit(1); }); }); gulp.task('dev', function() { return gulp.watch(['test/**/*.js', 'lib/**/*.js'], ['lint']); });