0.3.5 • Published 5 months ago
@ms-cloudpack/file-watcher v0.3.5
@ms-cloudpack/file-watcher
An abstraction on the file watching capabilities used in Cloudpack.
Example usage
- Create a watcher:
const watcher = createWatcher();- Subscribe to a particular package path using
watch. (Returns anunwatchfunction.)
const unwatch = watcher.watch({ path: 'path/to/package' }, () => console.log(`package changed`));- To dispose, call the returned
unwatch, or callwatcher.disposeto unsubscribe from all watchers.
// Dispose an individual watcher.
await unwatch();
// Dispose all watchers.
await watcher.dispose();createWatcher options
type('default' | 'fork', optional): By default, this will create a watcher in the same thread. Usetype: 'fork'to create the watcher in a forked process.
watcher.watch options
path(string): The absolute root path to be watched.id(string, optional): ID for the watch job (defaults topath). If you callwatchtwice using the sameid, subsequent calls will be ignored.watchedPaths(string[], optional): Relative paths/globs from the root path to watch. Defaults are under "@ms-cloudpack/path-utilities" insourceFilesGlobs.