lib/robol.js
function(cfg, callback) {
  var paths = cfg.input_files || cfg.input_file || cfg.input_dir;
  if (!Array.isArray(paths)) {
    paths = [paths];
  }
  
  watchr.watch({
    paths: paths,
    listener: function(eventName,filePath,fileCurrentStat,filePreviousStat){
      console.log(formatLog('File changed:', filePath));
      
      var singleFileCfg,
          outputDir,
          logTaskError = function(msg) {
            console.log('\n'+msg.red);
          };

      // Detect what build configuration the file belongs to
      if (config.scripts.indexOf(cfg) !== -1) {
        // rebuild scripts
        buildScripts(cfg, function(err){
          if (err) {
            logTaskError('Scripts not saved!');
          }
        });
      } else if (config.styles.indexOf(cfg) !== -1) {
        // rebuild styles
        buildStyles(cfg, function(err){
          if (err) {
            logTaskError('Styles not saved!');
          }
        });
      } else if (config.copy_files.indexOf(cfg) !== -1) {
        // copy files
        singleFileCfg = {input_files: [filePath], output_dir: cfg.output_dir};
        copyFiles(singleFileCfg, function(err){
          if (err) {
            logTaskError('File not copied!');
          }
        });
      } else if (config.copy_file.indexOf(cfg) !== -1) {
        // copy/rename single file
        singleFileCfg = {input_file: filePath, output_file: cfg.output_file};
        copyFile(singleFileCfg, function(err){
          if (err) {
            logTaskError('File not copied!');
          }
        });
      } else if (config.copy_dir.indexOf(cfg) !== -1) {
        // copy single directory
        outputDir = path.dirname(filePath).replace(cfg.input_dir, cfg.output_dir);
        singleFileCfg = {input_files: [filePath], output_dir: outputDir};
        copyFiles(singleFileCfg, function(err){
          if (err) {
            logTaskError('Directory not copied!');
          }
        });
      }
    },
    next: function(err,watcher){
      if (err) {
        callback(err);
      } else {
        callback();
      }
    }
  });
}
function(cfg, callback) {
  var paths = cfg.input_files || cfg.input_file || cfg.input_dir;
  if (!Array.isArray(paths)) {
    paths = [paths];
  }
  
  watchr.watch({
    paths: paths,
    listener: function(eventName,filePath,fileCurrentStat,filePreviousStat){
      console.log(formatLog('File changed:', filePath));
      
      var singleFileCfg,
          outputDir,
          logTaskError = function(msg) {
            console.log('\n'+msg.red);
          };

      // Detect what build configuration the file belongs to
      if (config.scripts.indexOf(cfg) !== -1) {
        // rebuild scripts
        buildScripts(cfg, function(err){
          if (err) {
            logTaskError('Scripts not saved!');
          }
        });
      } else if (config.styles.indexOf(cfg) !== -1) {
        // rebuild styles
        buildStyles(cfg, function(err){
          if (err) {
            logTaskError('Styles not saved!');
          }
        });
      } else if (config.copy_files.indexOf(cfg) !== -1) {
        // copy files
        singleFileCfg = {input_files: [filePath], output_dir: cfg.output_dir};
        copyFiles(singleFileCfg, function(err){
          if (err) {
            logTaskError('File not copied!');
          }
        });
      } else if (config.copy_file.indexOf(cfg) !== -1) {
        // copy/rename single file
        singleFileCfg = {input_file: filePath, output_file: cfg.output_file};
        copyFile(singleFileCfg, function(err){
          if (err) {
            logTaskError('File not copied!');
          }
        });
      } else if (config.copy_dir.indexOf(cfg) !== -1) {
        // copy single directory
        outputDir = path.dirname(filePath).replace(cfg.input_dir, cfg.output_dir);
        singleFileCfg = {input_files: [filePath], output_dir: outputDir};
        copyFiles(singleFileCfg, function(err){
          if (err) {
            logTaskError('Directory not copied!');
          }
        });
      }
    },
    next: function(err,watcher){
      if (err) {
        callback(err);
      } else {
        callback();
      }
    }
  });
}
function ( cfg , callback ) { var paths = cfg . input_files || cfg . input_file || cfg . input_dir ; if ( ! Array . isArray ( paths ) ) { paths = [ paths ] ; } watchr . watch ( { paths : paths , listener : function ( eventName , filePath , fileCurrentStat , filePreviousStat ) { console . log ( formatLog ( 'File changed:' , filePath ) ) ; var singleFileCfg , outputDir , logTaskError = function ( msg ) { console . log ( '\n' + msg . red ) ; } ; // Detect what build configuration the file belongs to if ( config . scripts . indexOf ( cfg ) !== - 1 ) { // rebuild scripts buildScripts ( cfg , function ( err ) { if ( err ) { logTaskError ( 'Scripts not saved!' ) ; } } ) ; } else if ( config . styles . indexOf ( cfg ) !== - 1 ) { // rebuild styles buildStyles ( cfg , function ( err ) { if ( err ) { logTaskError ( 'Styles not saved!' ) ; } } ) ; } else if ( config . copy_files . indexOf ( cfg ) !== - 1 ) { // copy files singleFileCfg = { input_files : [ filePath ] , output_dir : cfg . output_dir } ; copyFiles ( singleFileCfg , function ( err ) { if ( err ) { logTaskError ( 'File not copied!' ) ; } } ) ; } else if ( config . copy_file . indexOf ( cfg ) !== - 1 ) { // copy/rename single file singleFileCfg = { input_file : filePath , output_file : cfg . output_file } ; copyFile ( singleFileCfg , function ( err ) { if ( err ) { logTaskError ( 'File not copied!' ) ; } } ) ; } else if ( config . copy_dir . indexOf ( cfg ) !== - 1 ) { // copy single directory outputDir = path . dirname ( filePath ) . replace ( cfg . input_dir , cfg . output_dir ) ; singleFileCfg = { input_files : [ filePath ] , output_dir : outputDir } ; copyFiles ( singleFileCfg , function ( err ) { if ( err ) { logTaskError ( 'Directory not copied!' ) ; } } ) ; } } , next : function ( err , watcher ) { if ( err ) { callback ( err ) ; } else { callback ( ) ; } } } ) ; }
Setup watching of changes in the input files

@param {Object} cfg Build configuration
@param {Function} callback Task complete callback
Setup watching of changes in the input files