Skip to content

Commit a19fd0e

Browse files
committed
fix(provider-core): key npm-global version caches by lookup environment
1 parent e064cc8 commit a19fd0e

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

‎packages/provider-core/src/server/maintenanceResolver.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ it.layer(
513513
ChildProcessSpawner.ChildProcessSpawner,
514514
stdoutSpawner(() => {
515515
probes++;
516-
return JSON.stringify(version);
516+
return JSON.stringify({ "@example/package-tool": { latest: version } });
517517
}),
518518
),
519519
Effect.tap((capabilities) =>
@@ -685,6 +685,7 @@ it.layer(
685685
packageName: "@example/package-tool",
686686
latestVersion: null,
687687
lookupLatestVersion: expect.anything(),
688+
latestVersionCacheKey: expect.any(String),
688689
update: {
689690
command: `npm install -g --prefix ${tempDir} --allow-scripts=@example/package-tool @example/package-tool@latest`,
690691
executable: "npm",

‎packages/provider-core/src/server/maintenanceResolver.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
949949
if (npmPrefix) {
950950
const services = yield* Effect.context<ProviderMaintenanceResolverServices>();
951951
// npm 12 requires script approval to install native binaries; older npm only warns about the flag.
952-
return makeProviderMaintenanceCapabilities({
952+
const capabilities = makeProviderMaintenanceCapabilities({
953953
provider: definition.provider,
954954
packageName,
955955
updateExecutable: "npm",
@@ -970,6 +970,15 @@ export const resolvePackageManagedProviderMaintenance = Effect.fn(
970970
Effect.provideContext(services),
971971
),
972972
});
973+
return {
974+
...capabilities,
975+
latestVersionCacheKey: [
976+
"npm-global",
977+
normalizeCommandPath(npmPrefix),
978+
packageName,
979+
environmentCacheKey(context.env),
980+
].join("\0"),
981+
};
973982
}
974983

975984
const homebrew = homebrewOwnershipFromCommandPath(context.realCommandPath);

0 commit comments

Comments
 (0)