Skip to content

Commit

Permalink
perf: skip existsSync check
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Feb 11, 2024
1 parent c8b5791 commit 48fa7a0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sources/corepackUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export async function installVersion(installTarget: string, locator: Locator, {s

const installFolder = path.join(installTarget, locator.name, version);

if (fs.existsSync(installFolder)) {
try {
const corepackFile = path.join(installFolder, `.corepack`);
const corepackContent = await fs.promises.readFile(corepackFile, `utf8`);
const corepackData = JSON.parse(corepackContent);
Expand All @@ -121,6 +121,10 @@ export async function installVersion(installTarget: string, locator: Locator, {s
hash: corepackData.hash as string,
location: installFolder,
};
} catch (err) {
if ((err as nodeUtils.NodeError).code !== `ENOENT`) {
throw err;
}
}

const defaultNpmRegistryURL = spec.url.replace(`{}`, version);
Expand Down

0 comments on commit 48fa7a0

Please sign in to comment.