mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-19 00:01:19 +00:00
* Allow selecting a specific shell Add --terminal-shell CLI flag to specify which shell ExecaTerminalProcess uses for inline command execution. The shell path is validated at the CLI layer and passed through the standard settings mechanism (BaseTerminal static getter/setter), matching how all other CLI terminal settings flow through the system. * test(cli): make shell path access test cross-platform
47 lines
1 KiB
TypeScript
47 lines
1 KiB
TypeScript
import fs from "fs/promises"
|
|
import { constants as fsConstants } from "fs"
|
|
import path from "path"
|
|
|
|
export type TerminalShellValidationResult =
|
|
| {
|
|
valid: true
|
|
shellPath: string
|
|
}
|
|
| {
|
|
valid: false
|
|
reason: string
|
|
}
|
|
|
|
export async function validateTerminalShellPath(rawShellPath: string): Promise<TerminalShellValidationResult> {
|
|
const shellPath = rawShellPath.trim()
|
|
|
|
if (!shellPath) {
|
|
return { valid: false, reason: "shell path cannot be empty" }
|
|
}
|
|
|
|
if (!path.isAbsolute(shellPath)) {
|
|
return { valid: false, reason: "shell path must be absolute" }
|
|
}
|
|
|
|
try {
|
|
const stats = await fs.stat(shellPath)
|
|
|
|
if (!stats.isFile()) {
|
|
return { valid: false, reason: "shell path must point to a file" }
|
|
}
|
|
|
|
if (process.platform !== "win32") {
|
|
await fs.access(shellPath, fsConstants.X_OK)
|
|
}
|
|
} catch {
|
|
return {
|
|
valid: false,
|
|
reason:
|
|
process.platform === "win32"
|
|
? "shell path does not exist or is not a file"
|
|
: "shell path does not exist, is not a file, or is not executable",
|
|
}
|
|
}
|
|
|
|
return { valid: true, shellPath }
|
|
}
|