()
| 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 |
no test coverage detected