MCPcopy
hub / github.com/webpack/webpack / addDirectoryChecked

Method addDirectoryChecked

lib/ContextModuleFactory.js:342–363  ·  view source on GitHub ↗
(ctx, directory, visited, callback)

Source from the content-addressed store, hash-verified

340 * @param {ResolveDependenciesCallback} callback callback
341 */
342 const addDirectoryChecked = (ctx, directory, visited, callback) => {
343 /** @type {NonNullable<InputFileSystem["realpath"]>} */
344 (fs.realpath)(directory, (err, _realPath) => {
345 if (err) return callback(err);
346 const realPath = /** @type {string} */ (_realPath);
347 if (visited.has(realPath)) return callback(null, []);
348 /** @type {Set<string> | undefined} */
349 let recursionStack;
350 addDirectory(
351 ctx,
352 directory,
353 (_, dir, callback) => {
354 if (recursionStack === undefined) {
355 recursionStack = new Set(visited);
356 recursionStack.add(realPath);
357 }
358 addDirectoryChecked(ctx, dir, recursionStack, callback);
359 },
360 callback
361 );
362 });
363 };
364
365 /**
366 * Adds the provided ctx to the context module factory.

Callers

nothing calls this directly

Calls 4

addDirectoryFunction · 0.85
callbackFunction · 0.50
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected