fix(update): retry npm updates without optional deps

This commit is contained in:
Peter Steinberger
2026-04-26 09:49:44 +01:00
parent 832bdbc777
commit 42487d0dac
3 changed files with 91 additions and 1 deletions

View File

@@ -37,6 +37,7 @@ import {
canResolveRegistryVersionForPackageTarget,
createGlobalInstallEnv,
cleanupGlobalRenameDirs,
globalInstallFallbackArgs,
globalInstallArgs,
resolveExpectedInstalledVersionFromSpec,
resolveGlobalInstallTarget,
@@ -407,6 +408,21 @@ async function runPackageInstallUpdate(params: {
});
const steps = [updateStep];
let finalInstallStep = updateStep;
if (updateStep.exitCode !== 0) {
const fallbackArgv = globalInstallFallbackArgs(installTarget, installSpec);
if (fallbackArgv) {
const fallbackStep = await runUpdateStep({
name: "global update (omit optional)",
argv: fallbackArgv,
env: installEnv,
timeoutMs: params.timeoutMs,
progress: params.progress,
});
steps.push(fallbackStep);
finalInstallStep = fallbackStep;
}
}
let afterVersion = beforeVersion;
const verifiedPackageRoot =
@@ -451,7 +467,10 @@ async function runPackageInstallUpdate(params: {
}
}
const failedStep = steps.find((step) => step.exitCode !== 0);
const failedStep =
finalInstallStep.exitCode !== 0
? finalInstallStep
: (steps.find((step) => step !== updateStep && step.exitCode !== 0) ?? null);
return {
status: failedStep ? "error" : "ok",
mode: manager,