@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 anunwatch
function.)
const unwatch = watcher.watch({ path: 'path/to/package' }, () => console.log(`package changed`));
- To dispose, call the returned
unwatch
, or callwatcher.unwatchAll
to unsubscribe from all watchers.
// Dispose an individual watcher.
await unwatch();
// Dispose all watchers.
await watcher.unwatchAll();
watcher.watch
options
Name | Type | Description |
---|---|---|
path |
string | The absolute base path to be watched. |
watchedPaths |
string[] | Relative paths from the base path to watch. Defaults to package.json and src/ folder. |