Skip to content

Commit

Permalink
fix: remove fsextra.access to avoid possible race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
mark-tate committed Oct 22, 2024
1 parent 37ffc62 commit 691d26d
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions packages/plugins/src/DocumentAssetsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,17 @@ const DocumentAssetsPlugin: PluginType<Page, DocumentAssetsPluginOptions> = {

let globbedImageDirs;
try {
await fsExtra.access(resolvedSrcDir);
globbedImageDirs = await glob(assetSubDir, {
cwd: resolvedSrcDir,
onlyDirectories: true
});
} catch (err) {
if (err.code === 'ENOENT') {
console.warn(`Warning: Directory ${resolvedSrcDir} does not exist.`);
} else {
console.error(`Error globbing ${assetSubDir} in ${srcDir}:`, err);
throw err;
if (globbedImageDirs.length === 0) {
console.warn(`Warning: No entries found for ${assetSubDir}. It may not exist.`);
continue;
}
}

if (!globbedImageDirs || globbedImageDirs?.length === 0) {
continue;
} catch (err) {
console.error(`Error globbing ${assetSubDir} in ${srcDir}:`, err);
throw err;
}

await fsExtra.ensureDir(outputDir);
Expand Down

0 comments on commit 691d26d

Please sign in to comment.