MCPcopy Index your code
hub / github.com/nodejs/node / #buildFileList

Method #buildFileList

lib/internal/vfs/watcher.js:247–269  ·  view source on GitHub ↗

* Builds the list of files to track for recursive watching. * @param {string} dirPath The directory path * @param {string} relativePath The relative path from the watched root

(dirPath, relativePath)

Source from the content-addressed store, hash-verified

245 * @param {string} relativePath The relative path from the watched root
246 */
247 #buildFileList(dirPath, relativePath) {
248 try {
249 const entries = this.#vfs.readdirSync(dirPath, { withFileTypes: true });
250 for (const entry of entries) {
251 const fullPath = join(dirPath, entry.name);
252 const relPath = relativePath ? join(relativePath, entry.name) : entry.name;
253
254 if (entry.isDirectory()) {
255 // Recurse into subdirectory
256 this.#buildFileList(fullPath, relPath);
257 } else {
258 // Track the file
259 const stats = this.#getStatsFor(fullPath);
260 this.#trackedFiles.set(fullPath, {
261 stats,
262 relativePath: relPath,
263 });
264 }
265 }
266 } catch {
267 // Directory might not exist or be readable
268 }
269 }
270
271 /**
272 * Builds a list of direct children to track for non-recursive watching.

Callers 1

constructorMethod · 0.95

Calls 5

#getStatsForMethod · 0.95
joinFunction · 0.50
readdirSyncMethod · 0.45
isDirectoryMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected