| 2151 | } |
| 2152 | |
| 2153 | async 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 | |
| 2181 | const lazyGlob = getLazy(() => require('internal/fs/glob').Glob); |
| 2182 | async function* glob(pattern, options) { |