MCPcopy
hub / github.com/webpack/webpack / tryLoadCurrent

Function tryLoadCurrent

lib/sharing/utils.js:321–362  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

319 };
320
321 const tryLoadCurrent = () => {
322 if (i >= descriptionFiles.length) {
323 const parentDirectory = dirname(fs, directory);
324 if (!parentDirectory || parentDirectory === directory) {
325 return callback(null, undefined, [
326 ...satisfiesDescriptionFileDataInternal.checkedFilePaths
327 ]);
328 }
329 return getDescriptionFile(
330 fs,
331 parentDirectory,
332 descriptionFiles,
333 callback,
334 satisfiesDescriptionFileDataInternal.check,
335 satisfiesDescriptionFileDataInternal.checkedFilePaths
336 );
337 }
338 const filePath = join(fs, directory, descriptionFiles[i]);
339 readJson(fs, filePath, (err, data) => {
340 if (err) {
341 if ("code" in err && err.code === "ENOENT") {
342 i++;
343 return tryLoadCurrent();
344 }
345 return callback(err);
346 }
347 if (!data || typeof data !== "object" || Array.isArray(data)) {
348 return callback(
349 new Error(`Description file ${filePath} is not an object`)
350 );
351 }
352 if (
353 typeof satisfiesDescriptionFileDataInternal.check === "function" &&
354 !satisfiesDescriptionFileDataInternal.check({ data, path: filePath })
355 ) {
356 i++;
357 satisfiesDescriptionFileDataInternal.checkedFilePaths.add(filePath);
358 return tryLoadCurrent();
359 }
360 callback(null, { data, path: filePath });
361 });
362 };
363 tryLoadCurrent();
364};
365

Callers 1

getDescriptionFileFunction · 0.85

Calls 8

dirnameFunction · 0.85
getDescriptionFileFunction · 0.85
joinFunction · 0.85
readJsonFunction · 0.85
isArrayMethod · 0.80
checkMethod · 0.65
callbackFunction · 0.50
addMethod · 0.45

Tested by

no test coverage detected