@@ -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" ;
813
914const tempDirs : string [ ] = [ ] ;
1015
@@ -64,6 +69,16 @@ describe("plain gh helpers", () => {
6469 ) . toBe ( ghPath ) ;
6570 } ) ;
6671
72+ 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+
6782 it ( "normalizes color environment for JSON-safe gh output" , ( ) => {
6883 expect (
6984 plainGhEnv ( {
@@ -135,5 +150,8 @@ describe("plain gh helpers", () => {
135150
136151 expect ( helper ) . toContain ( "type -P gh" ) ;
137152 expect ( 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} ) ;
0 commit comments