How to use the gulp.on function in gulp

To help you get started, we’ve selected a few gulp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github stefanwalther / sense-go / test / 01-index.spec.js View on Github external
it( 'reduces all .less files to a single .css file', function ( done ) {
			gulp.start.apply( gulp, ['lessReduce'] );
			gulp.on('task_stop', function ( e ) {
				expect( path.join( __dirname, './tmp/lessReduce/root.css' ) ).to.be.a.file().and.not.empty;
				expect( path.join( __dirname, './tmp/lessReduce/root.css' ) ).to.have.content( fs.readFileSync( path.join( __dirname, './expected/lessReduce/root.css'), 'utf8'));

				// Todo: doesn't work
				//expect( path.join( __dirname, './tmp/lessReduce/variables.css' ) ).to.not.be.a.file();
				//expect( path.join( __dirname, './tmp/lessReduce/whatever.css' ) ).to.not.be.a.file();
				done();
			});
		} );
github pubnub / javascript / gulpfile.babel.js View on Github external
const uglify = require('gulp-uglify');
const rename = require('gulp-rename');
const exec = require('child_process').exec;
const Karma = require('karma').Server;
const mocha = require('gulp-mocha');
const runSequence = require('gulp4-run-sequence');
const gulpIstanbul = require('gulp-istanbul');
const sourcemaps = require('gulp-sourcemaps');
const packageJSON = require('./package.json');
const gzip = require('gulp-gzip');
const unzip = require('gulp-unzip');

// increase mocha timeout from default of 2000 to allow long running async tests to complete
const mochaTimeout = 5000;

gulp.on('error', process.exit.bind(process, 1));
gulp.task('clean', () => {
  return gulp
    .src(['lib', 'dist', 'coverage', 'upload'], { read: false, allowEmpty: true })
    .pipe(clean());
});

gulp.task('babel', () => {
  return gulp
    .src('src/**/*.js')
    .pipe(sourcemaps.init())
    .pipe(babel())
    .pipe(sourcemaps.write('.'))
    .pipe(gulp.dest('lib'));
});

gulp.task('unzip_titanium_sdk', () => {
github thenativeweb / roboter / lib / roboter.js View on Github external
}

  // Register custom tasks.
  Object.keys(this.tasks).
    filter(taskName => taskName.startsWith('custom/')).
    forEach(taskName => {
      const task = this.tasks[taskName];

      if (gulp.tasks[task.name]) {
        throw new Error('Can not overwrite built-in task.');
      }

      gulp.task(task.name, task.dependencies, task.code);
    });

  gulp.on('stop', () => {
    if (this.isWatching) {
      return;
    }
    /* eslint-disable no-process-exit */
    process.exit();
    /* eslint-enable no-process-exit */
  });
};
github n3-charts / line-chart / gulpfile.js View on Github external
callback);
});

gulp.task('travis:react', function(callback) {
  return runSequence(
    ['clean:source', 'clean:test'],
    ['src:compile:react', 'scss:copy'],
    ['unit:test'],
    ['e2e:test:react'],
    'coveralls',
  callback);
});

// Workaround to stop gulp after async task
// https://github.com/gulpjs/gulp/issues/167
gulp.on('stop', function() {
  if (!isWatching) {
    process.nextTick(function() {
      process.exit(0);
    });
  }
});

// Default task running `gulp`
gulp.task('default', ['build']);
github eden-js / cli / core / cli / core.js View on Github external
runHandler(args) {
    // run gulp logic (imports are local here for CLI optimization)
    const gulp = require('gulp'); // eslint-disable-line global-require
    require(path.join(global.edenRoot, 'gulpfile.js')); // eslint-disable-line global-require, import/no-dynamic-require

    // logged errors
    const loggedErrors = [];

    // add start logging
    gulp.on('start', (evt) => {
      this._logger.log(evt.branch ? 'debug' : 'info', `[${chalk.cyan(evt.name)}] Starting`);
    });

    // add stop logging
    gulp.on('stop', (evt) => {
      this._logger.log(evt.branch ? 'debug' : 'info', `[${chalk.cyan(evt.name)}] Finished in ${chalk.magenta(prettyTime(evt.duration))}`);
    });

    // on error
    gulp.on('error', (evt) => {
      this._logger.log(evt.branch ? 'debug' : 'error', `[${chalk.cyan(evt.name)}] Errored after ${chalk.magenta(prettyTime(evt.duration))}`);
      if (!loggedErrors.includes(evt.error)) {
        loggedErrors.push(evt.error);
        global.printError(evt.error);
      }
    });

    // run task
    return new Promise((resolve, reject) => {
      // gulp series
      gulp.series([args.fn === 'dev' ? 'default' : args.fn])((err) => {
github stellar-deprecated / stex / lib / dev / gulp.js View on Github external
module.exports = function() {

  var StexDev = require("../stex-dev.js");
  var plugins = StexDev.gulpPlugins();
  var paths   = StexDev.paths;
  var gulp    = require("gulp");
  var Promise = require("bluebird");
  var _       = require('lodash');
  var runSequence = require("run-sequence");

  gulp.on('stop', shutdown);
  gulp.on('err', shutdown);

  addAppTasks();
  addTestTasks();
  addDbTasks();

  // REMOVED until we can figure out why jsdoc continually breaks the build
  // gulp.task('docs', function() {
  //   return gulp.src(paths.docs)
  //     .pipe(plugins.jsdoc.parser({}))
  //     .pipe(plugins.jsdoc.generator('./docs'));
  // });

  gulp.task('watch', function() {
    gulp.run('test');
    gulp.watch(paths.watch, ['test']);
github railsware / upterm / gulpfile.js View on Github external
//TODO: Use gulp 4.
const gulp        = require('gulp');
const $           = require('gulp-load-plugins')();
const runSequence = require('run-sequence').use(gulp);

var watching = false;

gulp.on('stop', function () {
    if (!watching) {
        process.nextTick(function () {
            process.exit(0);
        });
    }
});

function onError(err) {
    var self = this;
    return $.notify.onError(function () {
        $.util.beep();
        $.util.log(err.toString());
        if (err.stack) {
            $.util.log('Stack trace', err.stack.toString());
        }
        self.emit('end');
github youzan / create-utils / packages / utils-scripts / src / cli / doc.ts View on Github external
import gulp from 'gulp';
import chalk from 'chalk';

import '../tasks';


gulp.on('error', e => console.log('error', e));

export default function() {
  gulp.task('publish-doc')((err) => {
    console.log('Automatically generate documents via esdoc');
    console.log(`Documents has been posted to the ${chalk.cyan('gh-pages')} branch`);
  });
}
github serviejs / popsicle / tasks / server.js View on Github external
gulp.task('server', function (done) {
  var app = server.listen(4567, done)

  function close () {
    app.close()

    gulp.removeListener('err', close)
    gulp.removeListener('stop', close)
  }

  gulp.on('err', close)
  gulp.on('stop', close)
})
github serviejs / popsicle / tasks / server.js View on Github external
gulp.task('server', function (done) {
  var app = server.listen(4567, done)

  function close () {
    app.close()

    gulp.removeListener('err', close)
    gulp.removeListener('stop', close)
  }

  gulp.on('err', close)
  gulp.on('stop', close)
})