How to use the watchr.create function in watchr

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 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 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

watchr

Better file system watching for Node.js

MIT
Latest version published 3 years ago

Package Health Score

57 / 100
Full package analysis