fix: use platform-aware binary detection (where on Windows, which on Unix)
This commit is contained in:
parent
78a08959f6
commit
b98697238b
@ -29,7 +29,7 @@ describe("gh cli check", () => {
|
|||||||
|
|
||||||
it("returns gh cli info structure", async () => {
|
it("returns gh cli info structure", async () => {
|
||||||
const spawnSpy = spyOn(Bun, "spawn").mockImplementation((cmd) => {
|
const spawnSpy = spyOn(Bun, "spawn").mockImplementation((cmd) => {
|
||||||
if (Array.isArray(cmd) && cmd[0] === "which" && cmd[1] === "gh") {
|
if (Array.isArray(cmd) && (cmd[0] === "which" || cmd[0] === "where") && cmd[1] === "gh") {
|
||||||
return createProc({ stdout: "/usr/bin/gh\n" })
|
return createProc({ stdout: "/usr/bin/gh\n" })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,8 @@ export interface GhCliInfo {
|
|||||||
|
|
||||||
async function checkBinaryExists(binary: string): Promise<{ exists: boolean; path: string | null }> {
|
async function checkBinaryExists(binary: string): Promise<{ exists: boolean; path: string | null }> {
|
||||||
try {
|
try {
|
||||||
const proc = Bun.spawn(["which", binary], { stdout: "pipe", stderr: "pipe" })
|
const whichCmd = process.platform === "win32" ? "where" : "which"
|
||||||
|
const proc = Bun.spawn([whichCmd, binary], { stdout: "pipe", stderr: "pipe" })
|
||||||
const output = await new Response(proc.stdout).text()
|
const output = await new Response(proc.stdout).text()
|
||||||
await proc.exited
|
await proc.exited
|
||||||
if (proc.exitCode === 0) {
|
if (proc.exitCode === 0) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user