fix: harden windows native updates

This commit is contained in:
Peter Steinberger
2026-03-12 23:41:28 +00:00
parent 35aafd7ca8
commit 91b701e183
7 changed files with 290 additions and 52 deletions

View File

@@ -24,6 +24,7 @@ import {
checkUpdateStatus,
} from "../../infra/update-check.js";
import {
createGlobalInstallEnv,
cleanupGlobalRenameDirs,
globalInstallArgs,
resolveGlobalPackageRoot,
@@ -269,6 +270,7 @@ async function runPackageInstallUpdate(params: {
installKind: params.installKind,
timeoutMs: params.timeoutMs,
});
const installEnv = await createGlobalInstallEnv();
const runCommand = createGlobalCommandRunner();
const pkgRoot = await resolveGlobalPackageRoot(manager, runCommand, params.timeoutMs);
@@ -287,6 +289,7 @@ async function runPackageInstallUpdate(params: {
const updateStep = await runUpdateStep({
name: "global update",
argv: globalInstallArgs(manager, `${packageName}@${params.tag}`),
env: installEnv,
timeoutMs: params.timeoutMs,
progress: params.progress,
});
@@ -380,6 +383,7 @@ async function runGitUpdate(params: {
name: "global install",
argv: globalInstallArgs(manager, updateRoot),
cwd: updateRoot,
env: await createGlobalInstallEnv(),
timeoutMs: effectiveTimeout,
progress: params.progress,
});
@@ -835,28 +839,29 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
}
}
const result = switchToPackage
? await runPackageInstallUpdate({
root,
installKind,
tag,
timeoutMs: timeoutMs ?? 20 * 60_000,
startedAt,
progress,
})
: await runGitUpdate({
root,
switchToGit,
installKind,
timeoutMs,
startedAt,
progress,
channel,
tag,
showProgress,
opts,
stop,
});
const result =
updateInstallKind === "package"
? await runPackageInstallUpdate({
root,
installKind,
tag,
timeoutMs: timeoutMs ?? 20 * 60_000,
startedAt,
progress,
})
: await runGitUpdate({
root,
switchToGit,
installKind,
timeoutMs,
startedAt,
progress,
channel,
tag,
showProgress,
opts,
stop,
});
stop();
printResult(result, { ...opts, hideSteps: showProgress });