Run a git command and return stdout. Throws on failure unless tolerateFailure is set.
(args: string[], cwd: string, tolerateFailure = false)
| 53 | |
| 54 | /** Run a git command and return stdout. Throws on failure unless tolerateFailure is set. */ |
| 55 | function git(args: string[], cwd: string, tolerateFailure = false): string { |
| 56 | const result = spawnSync('git', args, { cwd, stdio: 'pipe', timeout: 30_000 }); |
| 57 | const stdout = result.stdout?.toString().trim() ?? ''; |
| 58 | const stderr = result.stderr?.toString().trim() ?? ''; |
| 59 | if (result.status !== 0 && !tolerateFailure) { |
| 60 | throw new Error(`git ${args.join(' ')} failed (exit ${result.status}): ${stderr || stdout}`); |
| 61 | } |
| 62 | return stdout; |
| 63 | } |
| 64 | |
| 65 | // --- Dedup index --- |
| 66 |
no test coverage detected