(projectRoot, command)
| 70 | } |
| 71 | |
| 72 | function runCommand(projectRoot, command) { |
| 73 | const parts = splitCommand(command); |
| 74 | if (parts.length === 0) return { status: 'skipped', exitCode: null, stdout: '', stderr: '' }; |
| 75 | |
| 76 | const isWindowsNpm = process.platform === 'win32' && parts[0] === 'npm'; |
| 77 | const executable = isWindowsNpm ? 'cmd.exe' : parts[0]; |
| 78 | const args = isWindowsNpm ? ['/d', '/s', '/c', 'npm', ...parts.slice(1)] : parts.slice(1); |
| 79 | const result = childProcess.spawnSync(executable, args, { |
| 80 | cwd: projectRoot, |
| 81 | encoding: 'utf8', |
| 82 | stdio: ['ignore', 'pipe', 'pipe'], |
| 83 | shell: false, |
| 84 | }); |
| 85 | |
| 86 | return { |
| 87 | status: result.status === 0 ? 'pass' : 'fail', |
| 88 | exitCode: result.status ?? 1, |
| 89 | stdout: result.stdout || '', |
| 90 | stderr: result.stderr || '', |
| 91 | error: result.error ? result.error.message : null, |
| 92 | }; |
| 93 | } |
| 94 | |
| 95 | function checkStatus(checks) { |
| 96 | if (checks.some((check) => check.status === 'fail')) return 'blocked'; |
no test coverage detected