fix: skip old-process config writes after git switch

This commit is contained in:
Peter Steinberger
2026-04-06 01:29:23 +01:00
parent 6c4e06cd4f
commit e0354e71eb
2 changed files with 33 additions and 22 deletions

View File

@@ -1028,6 +1028,7 @@ describe("update-cli", () => {
await updateCommand({ channel: "dev", yes: true });
expect(syncPluginsForUpdateChannel).not.toHaveBeenCalled();
expect(replaceConfigFile).not.toHaveBeenCalled();
expect(defaultRuntime.exit).not.toHaveBeenCalledWith(1);
expect(
vi

View File

@@ -1040,28 +1040,38 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
let postUpdateConfigSnapshot = configSnapshot;
if (requestedChannel && configSnapshot.valid && requestedChannel !== storedChannel) {
const next = {
...configSnapshot.config,
update: {
...configSnapshot.config.update,
channel: requestedChannel,
},
};
await replaceConfigFile({
nextConfig: next,
baseHash: configSnapshot.hash,
});
postUpdateConfigSnapshot = {
...configSnapshot,
hash: undefined,
parsed: next,
sourceConfig: asResolvedSourceConfig(next),
resolved: asResolvedSourceConfig(next),
runtimeConfig: asRuntimeConfig(next),
config: asRuntimeConfig(next),
};
if (!opts.json) {
defaultRuntime.log(theme.muted(`Update channel set to ${requestedChannel}.`));
if (switchToGit) {
if (!opts.json) {
defaultRuntime.log(
theme.muted(
`Skipped persisting update.channel=${requestedChannel} in the pre-update CLI process after switching to a git install.`,
),
);
}
} else {
const next = {
...configSnapshot.config,
update: {
...configSnapshot.config.update,
channel: requestedChannel,
},
};
await replaceConfigFile({
nextConfig: next,
baseHash: configSnapshot.hash,
});
postUpdateConfigSnapshot = {
...configSnapshot,
hash: undefined,
parsed: next,
sourceConfig: asResolvedSourceConfig(next),
resolved: asResolvedSourceConfig(next),
runtimeConfig: asRuntimeConfig(next),
config: asRuntimeConfig(next),
};
if (!opts.json) {
defaultRuntime.log(theme.muted(`Update channel set to ${requestedChannel}.`));
}
}
}