How to use node-watch - 8 common examples

To help you get started, we’ve selected a few node-watch 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 thorgate / django-project-template / {{cookiecutter.repo_name}} / {{cookiecutter.repo_name}} / app-spa / cfg / helpers / start-host.js View on Github external
cwd: path.join(__dirname, '..', '..', '..')
                        }, (err, stdout, stderr) => {
                            logger.debug('Constants updated');

                            logger.debug(`err: ${err}`);
                            logger.debug(`stdout: ${stdout}`);
                            logger.debug(`stderr: ${stderr}`);
                        });

                    } else {
                        help();
                    }
                });

                // Start watcher on server files
                watch(path.join(__dirname, '../../src'), (file) => !file.match('stats.json') ? restartServer() : noop());
            }
        }
    });
};
github anther / smashladder-desktop / app / actions / replayBrowse.js View on Github external
}
	const slippiBuildPaths = slippiBuilds.map((build) => build.getSlippiPath());
	if (slippiBuildPaths.length === 0) {
		dispatch({
			type: REPLAY_BROWSE_FAIL
		});
		return;
	}

	const limitedUpdateBrowsedReplayList = _.debounce(() => {
		dispatch(updateBrowsedReplayList());
	}, replayCheckDelay, {
		leading: false,
		trailing: true
	});
	const newWatcher = watch(slippiBuildPaths, { recursive: true }, (event, filePath) => {
		// Just brute force it for now, people with thousands of games will suffer...
		limitedUpdateBrowsedReplayList();
	});
	dispatch({
		type: REPLAY_BROWSE_START,
		payload: {
			replayBrowseWatchProcess: newWatcher,
			replayWatchBuilds: slippiBuilds
		}
	});
	dispatch(updateBrowsedReplayList());
};
github anther / smashladder-desktop / app / utils / ReplaySyncer.js View on Github external
startWatchingIfSettingsAreGood() {
		if(this.watcher)
		{
			this.watcher.close();
		}
		if(!this._getRootPath())
		{
			console.log('can not start watching since root path is not set');
			return;
		}
		this.watcher = watch(this._getRootPath(), {recursive: false}, (event, filePath) => {
			if (event == 'remove') {
				return;
			}
			fs.lstat(filePath, (err, stats) => {
				if (err) {
					return console.log(err); //Handle error
				}
				else {
					if (stats.isFile()) {
						this.slippiGame = null;
						this.updateLastGame(filePath);
					}
				}
			});
		});
	}
github anther / smashladder-desktop / app / actions / replayWatch.js View on Github external
console.log('checking due to fresh file update');
		checkReplay(replay, replayWatchProcessCounter, dispatch, getState)
			.catch((error) => {
				console.log('oh well');
				console.error(error);
			});
	}, 5000, {
		leading: false,
		trailing: true
	});

	try {
		if (replayWatchProcess) {
			dispatch(stopWatchingForReplayChanges('Starting a new watch process'));
		}
		replayWatchProcess = watch(
			paths,
			{ recursive: false },
			(event, filePath) => {
				if (event === 'remove') {
					return;
				}

				const { verifyingReplayFiles } = getState().replayWatch;

				if (verifyingReplayFiles[filePath]) {
					const replay = Replay.retrieve({ id: filePath });
					console.log('what to check');
					limitedCheckReplay(replay);
				} else {
					fs.lstat(filePath, (err, stats) => {
						if (err) {
github transloadit / transloadify / src / assemblies-create.js View on Github external
fs.stat(file, (err, stats) => {
      if (err) return this.emit('error', err)
      let topdir = stats.isDirectory() ? file : undefined

      let watcher = watch(file, { recursive, followSymLinks: true })

      watcher.on('error', err => this.emit('error', err))
      watcher.on('end', () => this.emit('end'))
      watcher.on('change', file => {
        file = path.normalize(file)
        fs.stat(file, (err, stats) => {
          if (err) return this.emit('error', err)
          if (stats.isDirectory()) return
          if (streamRegistry[file]) streamRegistry[file].end()
          outstreamProvider(file, topdir).then(outstream => {
            streamRegistry[file] = outstream

            let instream = fs.createReadStream(file)
            this.emit('job', { in: instream, out: outstream })
          })
        })
github rung-tools / rung-cli / src / live.js View on Github external
function watchChanges(io, params) {
    const folder = process.cwd();
    return watch(folder, { recursive: true }, () => {
        emitInfo('changes detected. Recompiling...');
        io.sockets.emit('load');
        const start = new Date().getTime();
        executeWithParams(params)
            .tap(alerts => {
                const ellapsed = new Date().getTime() - start;
                emitSuccess(`wow! recompiled and executed in ${ellapsed}ms!`);
                io.sockets.emit('update', compileMarkdown(alerts));
            })
            .catch(err => {
                emitError(`hot compilation error, baby: ${err.message}`);
                io.sockets.emit('failure', err.stack);
            });
    });
}
github microsoft / botbuilder-js / libraries / botbuilder-dialogs-declarative / src / resources / folderResoureProvider.ts View on Github external
extensionsToInclude.forEach(e => this.extensions.add(e));

        this.IncludeSubFolders = includeSubFolders;
        folder = normalize(folder);
        this.Directory = folder;
        const allFiles: string[] = PathUtil.GetAllFiles(folder);
        const allFilteredFiles: string[] = allFiles.filter(f => this.extensions.has(extname(f)));

        allFilteredFiles.forEach(f => {
            const fileResource: FileResource = new FileResource(f);
            this.resources.set(fileResource.id(), fileResource);
        });

        if (monitorChanges) {
            watch(folder, { recursive: true }, (type, filename) => {
                this._emitter.emit("changed", new FileResource(filename));
            });
        }
    }
github mvila / radium-starter / builder.js View on Github external
async watchStaticFiles() {
    const filePaths = this.staticFilePaths.map(path => {
      if (typeof path === 'object') {
        path = path.src;
      }
      return pathModule.join(this.sourceDir, path);
    });
    watch(filePaths, async () => {
      try {
        await this.copyStaticFiles();
      } catch (err) {
        console.error(err);
      }
    });
  }

node-watch

A wrapper and enhancements for fs.watch

MIT
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis

Popular node-watch functions