From c26cfe03257fb7e6ddd03bde9090d1f0c14bb236 Mon Sep 17 00:00:00 2001 From: Yimo Jiang Date: Tue, 12 May 2026 19:38:58 +0000 Subject: [PATCH] fix(installer): dedupe user shim log Make ensure_cli_shim return early when the existing executable shim already matches the expected wrapper content, so the install-plus-verify path refreshes PATH/profile without rewriting or logging a second creation line. Signed-off-by: Yimo Jiang --- scripts/install.sh | 16 +++++++++++++--- test/install-preflight.test.ts | 19 ++++++++++++++++--- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/scripts/install.sh b/scripts/install.sh index 0487e772cb2..01cca8e355f 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -995,7 +995,7 @@ prefer_user_local_openshell() { ensure_cli_shim() { local cli_bin="${1:-$_CLI_BIN}" - local npm_bin shim_path node_path node_dir cli_path + local npm_bin shim_path node_path node_dir cli_path expected_shim npm_bin="$(resolve_npm_bin)" || true shim_path="${NEMOCLAW_SHIM_DIR}/${cli_bin}" @@ -1024,12 +1024,22 @@ ensure_cli_shim() { return 0 fi - mkdir -p "$NEMOCLAW_SHIM_DIR" - cat >"$shim_path" <"$shim_path" chmod +x "$shim_path" refresh_path ensure_local_bin_in_profile diff --git a/test/install-preflight.test.ts b/test/install-preflight.test.ts index a34f8253566..7d6189ecdc9 100644 --- a/test/install-preflight.test.ts +++ b/test/install-preflight.test.ts @@ -1355,11 +1355,22 @@ exit 99 if [ "\${1:-}" = "-c" ]; then shift 2 fi -if [ "$1" = "clone" ]; then +if [ "\${1:-}" = "-C" ]; then + shift 2 +fi +if [ "$1" = "init" ]; then target="\${@: -1}" - mkdir -p "$target/nemoclaw" + mkdir -p "$target/nemoclaw" "$target/scripts" echo '{"name":"nemoclaw","version":"0.1.0","dependencies":{"openclaw":"2026.3.11"}}' > "$target/package.json" echo '{"name":"nemoclaw-plugin","version":"0.1.0"}' > "$target/nemoclaw/package.json" + cat > "$target/scripts/install-openshell.sh" <<'EOS' +#!/usr/bin/env bash +exit 0 +EOS + chmod +x "$target/scripts/install-openshell.sh" + exit 0 +fi +if [ "$1" = "remote" ] || [ "$1" = "fetch" ] || [ "$1" = "checkout" ]; then exit 0 fi exit 0 @@ -1448,7 +1459,9 @@ exit 0 expect(result.status).toBe(0); expect(fs.readFileSync(shimPath, "utf-8")).toContain(`export PATH="${fakeBin}:$PATH"`); expect(fs.readFileSync(shimPath, "utf-8")).toContain(path.join(prefix, "bin", "nemoclaw")); - expect(`${result.stdout}${result.stderr}`).toMatch(/Created user-local shim/); + expect(`${result.stdout}${result.stderr}`.match(/Created user-local shim/g) ?? []).toHaveLength( + 1, + ); }); it("preserves ready output when nemoclaw is already resolvable after install", () => {