Watch for file system events against one or more paths
, which can be files or directories. These paths must exist already. One user action (e.g. touch test.file
) can generate multiple file system events. Likewise, one user action can result in multiple file paths in one event (e.g. mv old_name.txt new_name.txt
). Recursive option is true
by default and, for directories, will watch the specified directory and all sub directories. Note that the exact ordering of the events can vary between operating systems.
const watcher = Deno.watchFs("/");
for await (const event of watcher) {
console.log(">>>> event", event);
// { kind: "create", paths: [ "/foo.txt" ] }
}
Requires allow-read
permission.
Call watcher.close()
to stop watching.
const watcher = Deno.watchFs("/");
setTimeout(() => {
watcher.close();
}, 5000);
for await (const event of watcher) {
console.log(">>>> event", event);
}
© 2018–2021 the Deno authors
https://doc.deno.land/deno/stable/~/Deno.watchFs