

















@@ -4,7 +4,12 @@ import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync
44import { tmpdir } from "node:os";
55import path from "node:path";
66import { afterEach, describe, expect, it } from "vitest";
7-import { execPlainGh, plainGhEnv, resolvePlainGhBin } from "../../scripts/lib/plain-gh.mjs";
7+import {
8+execPlainGh,
9+plainGhEnv,
10+PLAIN_GH_SYSTEM_CANDIDATES,
11+resolvePlainGhBin,
12+} from "../../scripts/lib/plain-gh.mjs";
813914const tempDirs: string[] = [];
1015@@ -64,6 +69,16 @@ describe("plain gh helpers", () => {
6469).toBe(ghPath);
6570});
667172+it("prefers package-manager gh paths over bin shims", () => {
73+const realGh = makeFakeGh();
74+const shimGh = makeFakeGh();
75+76+expect(resolvePlainGhBin({ PATH: shimGh }, [realGh, shimGh])).toBe(realGh);
77+expect(PLAIN_GH_SYSTEM_CANDIDATES.indexOf("/opt/homebrew/opt/gh/bin/gh")).toBeLessThan(
78+PLAIN_GH_SYSTEM_CANDIDATES.indexOf("/opt/homebrew/bin/gh"),
79+);
80+});
81+6782it("normalizes color environment for JSON-safe gh output", () => {
6883expect(
6984plainGhEnv({
@@ -135,5 +150,8 @@ describe("plain gh helpers", () => {
135150136151expect(helper).toContain("type -P gh");
137152expect(helper).not.toContain("command -v gh");
153+expect(helper.indexOf("/opt/homebrew/opt/gh/bin/gh")).toBeLessThan(
154+helper.indexOf("/opt/homebrew/bin/gh"),
155+);
138156});
139157});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。