Skip to content

Commit b279853

Browse files
authored
1 parent 743e797 commit b279853

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

‎src/cli/update-cli.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5290,7 +5290,8 @@ describe("update-cli", () => {
52905290
"continues package-to-Git updates from the published checkout after its alias is retargeted",
52915291
async () => {
52925292
const root = await createTrackedTempDir("openclaw-update-git-alias-");
5293-
const packageRoot = path.join(root, "package", "openclaw");
5293+
const nodeModules = path.join(root, "package", "node_modules");
5294+
const packageRoot = path.join(nodeModules, "openclaw");
52945295
const targetRoot = path.join(root, "checkout-target");
52955296
const replacementRoot = path.join(root, "checkout-replacement");
52965297
const checkoutAlias = path.join(root, "checkout-alias");
@@ -5304,6 +5305,12 @@ describe("update-cli", () => {
53045305
return makeOkUpdateResult({ mode: "git", root: targetRoot });
53055306
});
53065307
vi.mocked(runCommandWithTimeout).mockImplementation(async (argv) => {
5308+
if (argv[1] === "--version") {
5309+
return commandResult({ stdout: "12.0.0\n" });
5310+
}
5311+
if (argv[0] === "npm" && argv[1] === "root" && argv[2] === "-g") {
5312+
return commandResult({ stdout: `${nodeModules}\n` });
5313+
}
53075314
if (argv[0] === "git" && argv[1] === "clone") {
53085315
const stagingDir = requireValue(argv.at(-1), "Git clone staging directory");
53095316
await fs.mkdir(path.join(stagingDir, ".git"), { recursive: true });

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,20 @@ export async function updateGitInstall(params: {
133133
allowGatewayServiceRepair: boolean;
134134
allowGatewayActivation: boolean;
135135
}): Promise<UpdateRunResult> {
136-
const requestedUpdateRoot = params.switchToGit ? resolveGitInstallDir() : params.root;
136+
let updateRoot = params.switchToGit ? resolveGitInstallDir() : params.root;
137137
const effectiveTimeout = params.timeoutMs ?? DEFAULT_UPDATE_STEP_TIMEOUT_MS;
138138
const installEnv = await createGlobalInstallEnv();
139139

140140
const checkout = params.switchToGit
141141
? await ensureGitCheckout({
142-
dir: requestedUpdateRoot,
142+
dir: updateRoot,
143143
env: installEnv,
144144
timeoutMs: effectiveTimeout,
145145
progress: params.progress,
146146
})
147147
: null;
148148
const cloneStep = checkout?.step ?? null;
149-
const updateRoot = checkout?.checkoutDir ?? requestedUpdateRoot;
149+
updateRoot = checkout?.checkoutDir ?? updateRoot;
150150

151151
if (cloneStep && cloneStep.exitCode !== 0) {
152152
const result: UpdateRunResult = {

0 commit comments

Comments
 (0)