Skip to content

Commit

Permalink
Don't early exit if using package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
mhan83 committed Oct 25, 2024
1 parent 83a6be9 commit 0c38dd3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/npm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ export default class NPM {

const exitCode = await exitPromise;

await this.restorePackageJson();

return exitCode;
}

Expand Down
10 changes: 6 additions & 4 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,24 @@ export async function prepareNpmEnv(
npmMetrics.data.rebuild = { duration: endTime - startTime };
}

if (Object.keys(packageList).length === 0) {
return npmMetrics;
}

// Ensure version is a string value as NPM only accepts strings.
const fixedPackageList = Object.fromEntries(
Object.entries(packageList).map(([k, v]) => [k, String(v)]),
);

// install npm packages
if (runCfg.npm?.usePackageLock !== true) {
if (Object.keys(fixedPackageList).length === 0) {
return npmMetrics;
}

await npm.renamePackageJson();
}
startTime = new Date().getTime();
await installNpmDependencies(nodeCtx, fixedPackageList);
endTime = new Date().getTime();

await npm.restorePackageJson();
npmMetrics.data.install = { duration: endTime - startTime };
return npmMetrics;
}
Expand Down

0 comments on commit 0c38dd3

Please sign in to comment.