Example #1
0
        fs.stat(inputPath, function (err, stat) {
            if (err) {
                return setTimeout(start, 500)
            }

            var handler

            if (stat.isFile()) {
                handler = handleFile.bind(null, inputPath, outputPath)
            } else {
                prepFolder()
                handler = handleFolder
            }

            var watcher = hound.watch(cwd, handler)

            watcher.on("create", reload)
            watcher.on("delete", reload)
            watcher.on("change", reload)

            function reload(fileName) {
                if (!filterIgnored(fileName)) {
                    handler()
                }
            }
        })
module.exports = functionalAPI = function functionalAPI(options, expressApp, callback) {
  var self = this;
  self.expressApp = expressApp;
  self.options = options;
  self.expressApp.use(bodyParser.json());
  self.publicAPI = {};
  self.watcher = hound.watch(shell.pwd() + self.options.folder);

  self.logger = {
    debug : (options.logger && options.logger.debug) || console.log,
    info : (options.logger && options.logger.info) || console.log,
    warn : (options.logger && options.logger.war) || console.log,
    error : (options.logger && options.logger.error) || console.log
  };

  self.logger.info('Creating mount path at [' + self.options.mountPath + ']');

  self.expressApp.use('/' + self.options.mountPath, function(request, response, next) {
    response.message = {
      error : true,
      errorMessage : 'ERROR: API call /' + self.mountPath + '/' + request.path + ' not found.',
      data : {}
    };
    next();
  });
};
Example #3
0
 .then(function () {
   var cycle = _.debounce(stopBuildStart, 1000);
   watcher = hound.watch('lib/');
   watcher.on('create', cycle);
   watcher.on('change', cycle);
   watcher.on('delete', cycle);
 });
Example #4
0
function registerDirectory(targetDirPath) {
    bus.db.emitStorePath(targetDirPath);
    bus.socket.emitUIEvent("register-path", targetDirPath);
    var watcher = hound.watch(targetDirPath);
    var artifactUnderTransfer;

    watcher.on('create', function(fsArtifact) {
        //Only move a direct child folder of the registered directory
        if (isDirectChildArtifact(targetDirPath, fsArtifact)) {
            artifactUnderTransfer = fsArtifact;
            bus.socket.emitUIEvent("start-blinking", targetDirPath);
            
            snitch.onStopGrowing(fsArtifact, function() {
                var artifactName = fsArtifact.replace(targetDirPath + "/", "").trim();
                bus.core.emitMoveToLetterDir(targetDirPath, artifactName);
                if (artifactUnderTransfer === fsArtifact) {
                    bus.socket.emitUIEvent("stop-blinking", targetDirPath);
                }
            });
            
        }
    });

    watcher.on('delete', function(file) {
        console.log(file + ' was deleted')
    })

    bus.onEvent('db', 'deletePath', function(path) {
        if (path === targetDirPath) {
            watcher.unwatch(path);
        }
    }).registerLocation(__filename);

}
Example #5
0
  client_manager.prototype.setupDirectoryWatching = function() {
    var self = this;
    var watcher = hound.watch(shell.pwd() + $cache.get('client_config.installation_path'));

    watcher.on('create', function(file, stats) {
      new file(file).readFile();
    });
    watcher.on('change', function(file, stats) {
      new file(file).readFile();
    });
  },
Example #6
0
DHTStore.prototype.watch = function (dir, opts) {
        if (self.watcher)
                self.watcher.clear();
        if (opts)
                debug (opts, 'NOT IMPLEMENTED');

        self.watcher = hound.watch (dir);
        ['change', 'create', 'delete'].forEach (function (signal) {
                self.watcher.on(signal, self.onChange);
        });
}
Example #7
0
function LiveReloadServer(options) {
    var server = http.createServer(serveText)
        , sock = shoe(handleStream)
        , cwd = options.cwd || process.cwd()
        , filterIgnored = options.ignore || noop

    var watcher = hound.watch(cwd)

    watcher.on("change", reload)
    watcher.on("create", reload)
    watcher.on("delete", reload)

    sock.install(server, "/shoe")

    return server

    function serveText(req, res) {
        res.end("live reload server running")
    }

    function handleStream(stream) {
        openStreams.push(stream)

        stream.on("end", remove)

        function remove() {
            var index = openStreams.indexOf(stream)
            if (index !== -1) {
                openStreams.splice(index, 1)
            }
        }
    }

    function reload(fileName) {
        if (!filterIgnored(fileName)) {
            openStreams.forEach(sendMessage)
        }
    }

    function sendMessage(stream) {
        stream && stream.write("reload")
    }
}
module.exports = staticAPI = function staticAPI(options, expressApp) {
    var self = this;
    self.options = options;
    self.expressApp = expressApp;
    self.publicAPI = {};
    self.watcher = hound.watch(shell.pwd() + self.options.folder);

    self.logger = {
      debug : (options.logger && options.logger.debug) || console.log,
      info : (options.logger && options.logger.info) || console.log,
      warn : (options.logger && options.logger.war) || console.log,
      error : (options.logger && options.logger.error) || console.log
    };

    self.logger.info('Creating mount path at [' + this.mountPath + ']');

    self.expressApp.use(self.options.mountPath, function(request, response, next) {
        next();
    });
};
Example #9
0
var NASA_LOGO = "C:\\DigitalSignage\\media\\piFilling\\nasameatball.png";
//this holds the folders with the symlinks the pi accesses  
var PIFOLDERS_ROOT = "C:\\DigitalSignage\\media\\piFolders";
//Location where the Pi can access the folders above, either SMB share or NFS
//	If NFS, the share must be mounted
var NFS_MNT_ROOT = "/media"

//--------------------------------------------------------------------------------------------------
// Pi Database Initialization
var db = new sqlite3.Database(DATABASE);
//Create Pidentiies if it is missing and add IPTV table & channels
database.init(DATABASE, fs, db);

//--------------------------------------------------------------------------------------------------
// Hound Filesystem Watching
watcher = hound.watch(MEDIA_ROOT);
fwd.init(fs, db, path);
watcher.on('create',fwd.updateFoldersCreate);
watcher.on('delete',fwd.updateFoldersDelete);

//Create the HTTP servers for the Emergency webpage and the Pi HTTP requests
var emergencyServer = express();
var piServer = express();

function createNewFolder(aPi){
	var promise = q.defer();
	
	var folder_loc = PIFOLDERS_ROOT + path.sep + aPi.getPiDee();
	console.log('Creating folder for '+aPi.getPiDee());
	mkdirp(folder_loc, function(error){
		if(error){
Example #10
0
      percent = Math.floor((passedTests/totalTests)*100) + '%';
    }

    log('TOTALS: %s failed; %s success', ratio, percent);
    log('TIME: %dms', Date.now()-start);
    complete && complete(!!failedTests);
  }

  process.nextTick(runNext);
  return function(fn) {
    cancel = fn;
  }
}

if (argv.w) {
  var watcher = hound.watch(__dirname + '/../lib');
  watcher.watch(__dirname + '/../context2d.js');
  watcher.watch(__dirname + '/../src');

  watcher.on('change', function(file) {
    if (file.match(/\.(h|cc|cpp|gyp)/)) {
      log('[recompiling]')
      var c = spawn('node', [
        'node_modules/pangyp/bin/node-gyp',
        'configure',
        'build',
        '--debug'
      ], {
        env: process.env,
        stdio: 'pipe'
      });