MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / validateTerminalShellPath

Function validateTerminalShellPath

apps/cli/src/lib/utils/shell.ts:15–47  ·  view source on GitHub ↗
(rawShellPath: string)

Source from the content-addressed store, hash-verified

13 }
14
15export async function validateTerminalShellPath(rawShellPath: string): Promise<TerminalShellValidationResult> {
16 const shellPath = rawShellPath.trim()
17
18 if (!shellPath) {
19 return { valid: false, reason: "shell path cannot be empty" }
20 }
21
22 if (!path.isAbsolute(shellPath)) {
23 return { valid: false, reason: "shell path must be absolute" }
24 }
25
26 try {
27 const stats = await fs.stat(shellPath)
28
29 if (!stats.isFile()) {
30 return { valid: false, reason: "shell path must point to a file" }
31 }
32
33 if (process.platform !== "win32") {
34 await fs.access(shellPath, fsConstants.X_OK)
35 }
36 } catch {
37 return {
38 valid: false,
39 reason:
40 process.platform === "win32"
41 ? "shell path does not exist or is not a file"
42 : "shell path does not exist, is not a file, or is not executable",
43 }
44 }
45
46 return { valid: true, shellPath }
47}

Callers 2

runFunction · 0.85
shell.test.tsFile · 0.85

Calls 1

statMethod · 0.80

Tested by

no test coverage detected