MCPcopy Create free account
hub / github.com/nodejs/node / _watch

Function _watch

lib/internal/fs/promises.js:2153–2179  ·  view source on GitHub ↗
(filename, options = kEmptyObject)

Source from the content-addressed store, hash-verified

2151}
2152
2153async function* _watch(filename, options = kEmptyObject) {
2154 const h = vfsState.handlers;
2155 if (h !== null) {
2156 const result = h.promisesWatch(filename, options);
2157 if (result !== undefined) {
2158 yield* result;
2159 return;
2160 }
2161 }
2162 validateObject(options, 'options');
2163
2164 if (options.recursive != null) {
2165 validateBoolean(options.recursive, 'options.recursive');
2166
2167 // TODO(anonrig): Remove non-native watcher when/if libuv supports recursive.
2168 // As of November 2022, libuv does not support recursive file watch on all platforms,
2169 // e.g. Linux due to the limitations of inotify.
2170 if (options.recursive && !isMacOS && !isWindows) {
2171 const watcher = new nonNativeWatcher.FSWatcher(options);
2172 watcher[kFSWatchStart](filename);
2173 yield* watcher;
2174 return;
2175 }
2176 }
2177
2178 yield* watch(filename, options);
2179}
2180
2181const lazyGlob = getLazy(() => require('internal/fs/glob').Glob);
2182async function* glob(pattern, options) {

Callers

nothing calls this directly

Calls 1

watchFunction · 0.70

Tested by

no test coverage detected