| 408 | // one-line "evolver needs a git workspace" notice, so a false negative just |
| 409 | // suppresses the notice rather than breaking anything. |
| 410 | function isGitWorkspace(dir) { |
| 411 | try { |
| 412 | const res = spawnSync('git', ['rev-parse', '--is-inside-work-tree'], { |
| 413 | cwd: dir, |
| 414 | encoding: 'utf8', |
| 415 | timeout: 5000, |
| 416 | stdio: ['ignore', 'pipe', 'pipe'], |
| 417 | shell: false, |
| 418 | windowsHide: true, |
| 419 | }); |
| 420 | return res.status === 0 && typeof res.stdout === 'string' && res.stdout.trim() === 'true'; |
| 421 | } catch { |
| 422 | return false; |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | module.exports = { |
| 427 | findEvolverRoot, |