src/run.js
function watch(sourcePath, patterns, commands) {
  var isBusy = false;
  var isPending = false;
  var runnable = function() {
    if (isBusy) return (isPending = true);
    isBusy = true;
    run(commands, function(err) {
      if (err) console.error(err.stack || err);
      isBusy = false;
      if (isPending) runnable(isPending = false);
    });
  };
  chokidar.watch(patterns, {
    cwd: sourcePath,
    ignoreInitial: true
  }).on('add', runnable).on('change', runnable).on('unlink', runnable);
}
function watch(sourcePath, patterns, commands) {
  var isBusy = false;
  var isPending = false;
  var runnable = function() {
    if (isBusy) return (isPending = true);
    isBusy = true;
    run(commands, function(err) {
      if (err) console.error(err.stack || err);
      isBusy = false;
      if (isPending) runnable(isPending = false);
    });
  };
  chokidar.watch(patterns, {
    cwd: sourcePath,
    ignoreInitial: true
  }).on('add', runnable).on('change', runnable).on('unlink', runnable);
}
function watch ( sourcePath , patterns , commands ) { var isBusy = false ; var isPending = false ; var runnable = function ( ) { if ( isBusy ) return ( isPending = true ) ; isBusy = true ; run ( commands , function ( err ) { if ( err ) console . error ( err . stack || err ) ; isBusy = false ; if ( isPending ) runnable ( isPending = false ) ; } ) ; } ; chokidar . watch ( patterns , { cwd : sourcePath , ignoreInitial : true } ) . on ( 'add' , runnable ) . on ( 'change' , runnable ) . on ( 'unlink' , runnable ) ; }
Watches the patterns in the source path and runs commands on changes.
@param {string} sourcePath
@param {(Array.<string>|string)} patterns
@param {Array.<string>} commands
Watches the patterns in the source path and runs commands on changes .