index.js
function watchFile(path, base, rootPath) {
  path = normalize(path);

  var log = '  ' + chalk.gray('watching') + ' ' + chalk.cyan(path);
  if (!base) {
    base = path;
  } else {
    base = normalize(base);
    log += '\n    ' + chalk.gray('as a dependency of') + ' ';
    log += chalk.cyan(base);
  }

  if (watchList[path]) {
    if (watchList[path].indexOf(base) !== -1) return;
    consoleLog(log);
    watchList[path].push(base);
    return;
  }

  consoleLog(log);
  watchList[path] = [base];
  fs.watchFile(path, {persistent: true, interval: 200},
               function (curr, prev) {
    // File doesn't exist anymore. Keep watching.
    if (curr.mtime.getTime() === 0) return;
    // istanbul ignore if
    if (curr.mtime.getTime() === prev.mtime.getTime()) return;
    watchList[path].forEach(function(file) {
      tryRender(file, rootPath);
    });
  });
}
function watchFile(path, base, rootPath) {
  path = normalize(path);

  var log = '  ' + chalk.gray('watching') + ' ' + chalk.cyan(path);
  if (!base) {
    base = path;
  } else {
    base = normalize(base);
    log += '\n    ' + chalk.gray('as a dependency of') + ' ';
    log += chalk.cyan(base);
  }

  if (watchList[path]) {
    if (watchList[path].indexOf(base) !== -1) return;
    consoleLog(log);
    watchList[path].push(base);
    return;
  }

  consoleLog(log);
  watchList[path] = [base];
  fs.watchFile(path, {persistent: true, interval: 200},
               function (curr, prev) {
    // File doesn't exist anymore. Keep watching.
    if (curr.mtime.getTime() === 0) return;
    // istanbul ignore if
    if (curr.mtime.getTime() === prev.mtime.getTime()) return;
    watchList[path].forEach(function(file) {
      tryRender(file, rootPath);
    });
  });
}
function watchFile ( path , base , rootPath ) { path = normalize ( path ) ; var log = '  ' + chalk . gray ( 'watching' ) + ' ' + chalk . cyan ( path ) ; if ( ! base ) { base = path ; } else { base = normalize ( base ) ; log += '\n    ' + chalk . gray ( 'as a dependency of' ) + ' ' ; log += chalk . cyan ( base ) ; } if ( watchList [ path ] ) { if ( watchList [ path ] . indexOf ( base ) !== - 1 ) return ; consoleLog ( log ) ; watchList [ path ] . push ( base ) ; return ; } consoleLog ( log ) ; watchList [ path ] = [ base ] ; fs . watchFile ( path , { persistent : true , interval : 200 } , function ( curr , prev ) { // File doesn't exist anymore. Keep watching. if ( curr . mtime . getTime ( ) === 0 ) return ; // istanbul ignore if if ( curr . mtime . getTime ( ) === prev . mtime . getTime ( ) ) return ; watchList [ path ] . forEach ( function ( file ) { tryRender ( file , rootPath ) ; } ) ; } ) ; }
Watch for changes on path

Renders `base` if specified, otherwise renders `path`.
Watch for changes on path