(cmd: string, opts?: { cwd?: string; input?: string })
| 31 | // ---- String-based commands (for static/trusted command strings only) ---- |
| 32 | |
| 33 | export function run(cmd: string, opts?: { cwd?: string; input?: string }): string { |
| 34 | const result = checkIntercept(cmd.split(/\s+/), opts); |
| 35 | if (result?.intercepted) { |
| 36 | if ('error' in result) throw new Error(result.error); |
| 37 | return result.result; |
| 38 | } |
| 39 | return execSync(cmd, { |
| 40 | cwd: opts?.cwd, |
| 41 | input: opts?.input, |
| 42 | encoding: 'utf-8', |
| 43 | stdio: [opts?.input ? 'pipe' : 'pipe', 'pipe', 'pipe'], |
| 44 | }).trim(); |
| 45 | } |
| 46 | |
| 47 | export function runAsync(cmd: string, opts?: { cwd?: string; input?: string }): Promise<string> { |
| 48 | const result = checkIntercept(cmd.split(/\s+/), opts); |
no test coverage detected