* Resolve the GitHub CLI executable path. * Checks native Windows install locations first, then falls back to PATH lookup. * Works correctly in Git Bash, native Windows, WSL, and Unix. * * @returns {string} Absolute path or 'gh' (relies on PATH)
()
| 59 | * @returns {string} Absolute path or 'gh' (relies on PATH) |
| 60 | */ |
| 61 | function resolveGhPath() { |
| 62 | if (process.platform === 'win32') { |
| 63 | const fs = require('fs'); |
| 64 | const candidates = [ |
| 65 | 'C:\\Program Files\\GitHub CLI\\gh.exe', |
| 66 | 'C:\\Program Files (x86)\\GitHub CLI\\gh.exe', |
| 67 | ]; |
| 68 | for (const candidate of candidates) { |
| 69 | try { |
| 70 | if (fs.existsSync(candidate)) return candidate; |
| 71 | } catch { |
| 72 | // Non-critical — fall through to PATH |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | // Unix, WSL, Git Bash, or gh not in standard locations — rely on PATH |
| 77 | return 'gh'; |
| 78 | } |
| 79 | |
| 80 | module.exports = { |
| 81 | toUniversal, |