Files
orca/tests/e2e/terminal-node-command.ts
T
Jinjing 55055b42af Use runner Node executable and platform quoting in terminal E2E tests (#5890)
Ensure terminal E2E probes run reliably on Windows CI, where the shell
does not always inherit setup-node's PATH.

- Add `nodeTerminalCommand` helper to resolve and quote `process.execPath`
  for either POSIX shells or PowerShell depending on the platform.
- Update terminal tests and probes to use the new helper instead of
  hardcoded `node` invocations.
2026-06-20 01:27:41 -07:00

21 lines
787 B
TypeScript

function quotePosixShellArg(value: string): string {
return `'${value.replaceAll("'", "'\\''")}'`
}
function quotePowerShellArg(value: string): string {
return `'${value.replaceAll("'", "''")}'`
}
function quoteTerminalArg(value: string): string {
return process.platform === 'win32' ? quotePowerShellArg(value) : quotePosixShellArg(value)
}
export function nodeTerminalCommand(args: readonly string[]): string {
const nodeExecutable = quoteTerminalArg(process.execPath)
const executable = process.platform === 'win32' ? `& ${nodeExecutable}` : nodeExecutable
// Why: Windows CI shells do not always inherit setup-node's PATH, so E2E
// terminal probes must invoke the runner's Node executable directly.
return [executable, ...args.map(quoteTerminalArg)].join(' ')
}