fix: add script to find the git binaries on Windows

This commit is contained in:
Amin Yahyaabadi 2025-03-08 23:29:53 -08:00
parent ae8148bb39
commit 873a0ce059
5 changed files with 25 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,5 @@
import { existsSync } from "fs"
import { warning } from "ci-log"
import { addPath } from "envosman"
import { installAptPack } from "setup-apt"
import { installBrewPack } from "setup-brew"
@ -14,8 +16,10 @@ export async function setupGit(version: string, _setupDir: string, _arch: string
switch (process.platform) {
case "win32": {
const result = await setupChocoPack("git", version)
result.binDir = "C:/Program Files (x86)/Git/bin"
await addPath(result.binDir, rcOptions)
const gitDir = findWindowsGit()
if (gitDir !== null) {
await addPath(gitDir, rcOptions)
}
return result
}
case "darwin": {
@ -36,3 +40,18 @@ export async function setupGit(version: string, _setupDir: string, _arch: string
}
}
}
function findWindowsGit() {
const candidates = [
"C:/Program Files/Git/bin/git.exe",
"C:/Program Files (x86)/Git/bin/git.exe",
]
for (const candidate of candidates) {
if (existsSync(candidate)) {
return candidate
}
}
warning("Git not found in the default locations. Add git to PATH manually.")
return null
}