How to use watchr - 10 common examples

To help you get started, we’ve selected a few watchr 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 Illizian / node-codekit / lib / node-codekit.js View on Github external
function watchInit() {
	console.log(ascii.color('\n    )     )  (               )  (            ', 'yellow'));
	console.log(ascii.color(' ( /(  ( /(  )\\ )         ( /(  )\\ )  *   )  ', 'red'));
	console.log(ascii.color(' )\\()) )\\())(()/(   (     )\\())(()/(` )  /(  ', 'red'));
	console.log(ascii.color('((_)\\ ((_)\\  /(_))  )\\  |((_)\\  /(_))( )(_)) ', 'red'));
	console.log(ascii.color(' _((_)  ((_)(_))_  ((_) |_ ((_)(_)) (_(_())  ', 'blue'));
	console.log(ascii.color('| \\| | / _ \\ |   \\ | __|| |/ / |_ _||_   _|  ', 'cyan'));
	console.log(ascii.color('| .` || (_) || |) || _|   \' <   | |   | |    ', 'cyan'));
	console.log(ascii.color('|_|\\_| \\___/ |___/ |___| _|\\_\\ |___|  |_|    ', 'cyan'));
	console.log(ascii.color('\n A Web Developer\'s Best Friend! \n', 'bold'))
	
	console.log('Watching: ' + process.cwd());
	notify('NodeKit', 'Watching: ' + process.cwd());
	// Watch the current working directory
	watchr.watch({
	    path: process.cwd(),
	    listener: function(eventName,filePath,fileCurrentStat,filePreviousStat) {
	        // Handle watch event
	        pre_process([eventName,filePath,fileCurrentStat,filePreviousStat]);
	    },
	    next: function(err,watcher) {
	        if (err)  throw err;
	    }
	});
	// Listen on socket channel
	io = require('socket.io').listen(8080)
	
	// Socket.IO configuration
	io.set('log level', 0);

	// Attach Socket.IO Events
github CodeboxIDE / codebox / core / cb.watch / init.js View on Github external
function init(logger, events, rootPath) {
    var d = Q.defer();

    // Normalize paths
    function normalize(fullPath) {
        return path.normalize(
            '/' + path.relative(rootPath, fullPath)
        );
    }

    logger.log('Starting Watch');
    // Construct
    watchr.watch({
        paths: [rootPath],

        // Following links causes issues with broken symlinks
        // crashing the whole watchr instance and thus codebox
        // so disabling link following for now
        followLinks: false,

        listeners: {
            log: function(logLevel) {
                /*
                events.emit('watch.log', {
                    level: logLevel,
                    args: _.toArray(arguments)
                });
                */
            },
github digiwano / auton / lib / watcher.js View on Github external
paths: this.paths,
    listeners: { // forward everything on to our eventemitter for now
      log      : function(level, info) {
        self.log( level === 'debug' ? 'debug-2' : level, info );
      },
      error    : this.emit.bind( this, 'error' ),
      change   : _change.bind( this )
    },
    next: function(err, watchers) {
      if (err) { this.emit('error', err); return callback(err); }
      self.watchers = watchers;
      self.log('debug', 'watching ' + self.watchers.length + ' files/dirs');
    }
  };
  var cfg = _.extend( {}, _defaultConfig, this.config )
  watchr.watch( cfg );
};
github CodeboxIDE / codebox / core / cb.watch / init.js View on Github external
function init(logger, events, rootPath) {
    var d = Q.defer();

    // Normalize paths
    function normalize(fullPath) {
        return path.normalize(
            '/' + path.relative(rootPath, fullPath)
        );
    }

    logger.log('Starting Watch');
    // Construct
    watchr.watch({
        paths: [rootPath],

        // Following links causes issues with broken symlinks
        // crashing the whole watchr instance and thus codebox
        // so disabling link following for now
        followLinks: false,

        listeners: {
            log: function(logLevel) {
                /*
                events.emit('watch.log', {
                    level: logLevel,
                    args: _.toArray(arguments)
                });
                */
            },
github last-hit-aab / last-hit / main / workspace-monitor.ts View on Github external
currentStat,
		previousStat
	) => {
		switch (changeType) {
			case WatchrChangeType.UPDATE:
				console.log('the file', fullPath, 'was updated'); //, currentStat, previousStat);
				break;
			case WatchrChangeType.CREATE:
				console.log('the file', fullPath, 'was created'); //, currentStat);
				break;
			case WatchrChangeType.DELETE:
				console.log('the file', fullPath, 'was deleted'); //, previousStat);
				break;
		}
	};
	const stalker = fsWathcer.create(rootFolder);
	stalker.on(WatchrEvent.CHANGE, listener);
	// stalker.on('log', console.log);
	stalker.once(WatchrEvent.CLOSE, (reason: string): void => {
		console.log('closed because', reason);
		stalker.removeAllListeners(); // as it is closed, no need for our change or log listeners any more
	});
	stalker.setConfig({
		stat: null,
		interval: 5007,
		persistent: true,
		catchupDelay: 2000,
		preferredMethods: [
			WatchrConfigPreferredMethod.WATCH,
			WatchrConfigPreferredMethod.WATCH_FILE
		],
		followLinks: true,
github cds-snc / security-goals / api / src / db / watcher / index.js View on Github external
const watchChecks = () => {
  // Watch the path with the change listener and completion callback
  return watchr.open(watchPath, listener, next)
}
github Syncano / syncano-node / packages / cli / src / commands / socket-deploy-hot.js View on Github external
runStalker () {
    // Stalking files
    debug('watching:', this.session.projectPath)
    this.stalker = watchr.create(this.session.projectPath)
    this.stalker.on('change', async (changeType, fileName) => {
      timer.reset()
      const socketToUpdate = this.getSocketToUpdate(fileName)
      if (socketToUpdate) {
        this.deploySocket(socketToUpdate)
      }
    })

    this.stalker.setConfig({
      interval: 300,
      persistent: true,
      catchupDelay: 300,
      preferredMethods: ['watch', 'watchFile'],
      followLinks: true,
      ignoreHiddenFiles: true, // ignoring .bundles, .dist etc.
      ignoreCommonPatterns: true
github ITEA3-Measure / MeasurePlatform / src / main / webapp / bower_components / messageformat / bin / messageformat.js View on Github external
},
      function() {
        var fn_str = mf.compile(messages, compileOpt).toString();
        fn_str = fn_str.replace(/^\s*function\b[^{]*{\s*/, '').replace(/\s*}\s*$/, '');
        var data = options.module ? fn_str : '(function(G) {\n' + fn_str + '\n})(this);';
        return callback(options, data.trim() + '\n');
      }
    );
  });
}

build(options, write);

if (options.watch) {
  _log('watching for changes in ' + options.inputdir + '...\n');
  require('watchr').watch({
    path: options.inputdir,
    ignorePaths: [ options.output ],
    listener: function(changeType, filePath) { if (/\.json$/.test(filePath)) build(options, write); }
  });
}
github howech / gestalt / lib / file.js View on Github external
}

    if( format ) {
	if( format != 'raw' ) {
	    this._options_.parser = this._options_.parser || parsers[ format ];
	} else {
	    this._options_parser = parsers[ 'rawFile' ];
	}
    }


    //console.log( "options: ", this._options_ );
    this.readFile();

    if( this._options_.watch ) {  
	this._watchr_ = watchr.watch( 
	    { path: this._source_,
	      listener: function(event, file, stat, ostat) {
		  if( event == 'change' ) {
		      self.readFile();
		  } else if (event == 'unlink' ) {
		      self.state('invalid', 'backing file deleted;');
		  }
	      }
	    });
    }
}
github austinsc / signal-arr-proxygen / src / cli.js View on Github external
.argv;

if(argv._.length < 2) {
  CFonts.say(' signal-arr', {colors: ['red', 'white'], maxLength: '11'});
  yargs.showHelp('log');
} else {
  argv.command = argv._[0];
  argv.assembly = argv._[1];
  argv.print = console.log;
  argv.writeFile = fs.writeFile;
  argv.readFile = fs.readFile;
  if(argv.command === 'interactive') {
    interactive(argv).catch(err => console.error(err));
  } else {
    if(argv.watch) {
      watchr.watch({
        path: argv.assembly,
        listener() {
          processor(argv).catch(err => console.error(err));
        }
      });
    }
    processor(argv).catch(err => console.error(err));
  }
}

watchr

Better file system watching for Node.js

MIT
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis