Skip to content

Commit e0354e7

Browse files
committed
fix: skip old-process config writes after git switch
1 parent 6c4e06c commit e0354e7

2 files changed

Lines changed: 33 additions & 22 deletions

File tree

src/cli/update-cli.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ describe("update-cli", () => {
10281028
await updateCommand({ channel: "dev", yes: true });
10291029

10301030
expect(syncPluginsForUpdateChannel).not.toHaveBeenCalled();
1031+
expect(replaceConfigFile).not.toHaveBeenCalled();
10311032
expect(defaultRuntime.exit).not.toHaveBeenCalledWith(1);
10321033
expect(
10331034
vi

src/cli/update-cli/update-command.ts

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,28 +1040,38 @@ export async function updateCommand(opts: UpdateCommandOptions): Promise<void> {
10401040

10411041
let postUpdateConfigSnapshot = configSnapshot;
10421042
if (requestedChannel && configSnapshot.valid && requestedChannel !== storedChannel) {
1043-
const next = {
1044-
...configSnapshot.config,
1045-
update: {
1046-
...configSnapshot.config.update,
1047-
channel: requestedChannel,
1048-
},
1049-
};
1050-
await replaceConfigFile({
1051-
nextConfig: next,
1052-
baseHash: configSnapshot.hash,
1053-
});
1054-
postUpdateConfigSnapshot = {
1055-
...configSnapshot,
1056-
hash: undefined,
1057-
parsed: next,
1058-
sourceConfig: asResolvedSourceConfig(next),
1059-
resolved: asResolvedSourceConfig(next),
1060-
runtimeConfig: asRuntimeConfig(next),
1061-
config: asRuntimeConfig(next),
1062-
};
1063-
if (!opts.json) {
1064-
defaultRuntime.log(theme.muted(`Update channel set to ${requestedChannel}.`));
1043+
if (switchToGit) {
1044+
if (!opts.json) {
1045+
defaultRuntime.log(
1046+
theme.muted(
1047+
`Skipped persisting update.channel=${requestedChannel} in the pre-update CLI process after switching to a git install.`,
1048+
),
1049+
);
1050+
}
1051+
} else {
1052+
const next = {
1053+
...configSnapshot.config,
1054+
update: {
1055+
...configSnapshot.config.update,
1056+
channel: requestedChannel,
1057+
},
1058+
};
1059+
await replaceConfigFile({
1060+
nextConfig: next,
1061+
baseHash: configSnapshot.hash,
1062+
});
1063+
postUpdateConfigSnapshot = {
1064+
...configSnapshot,
1065+
hash: undefined,
1066+
parsed: next,
1067+
sourceConfig: asResolvedSourceConfig(next),
1068+
resolved: asResolvedSourceConfig(next),
1069+
runtimeConfig: asRuntimeConfig(next),
1070+
config: asRuntimeConfig(next),
1071+
};
1072+
if (!opts.json) {
1073+
defaultRuntime.log(theme.muted(`Update channel set to ${requestedChannel}.`));
1074+
}
10651075
}
10661076
}
10671077

0 commit comments

Comments
 (0)