(
command: string,
args: string[],
options: {
cwd?: string;
env?: NodeJS.ProcessEnv;
input?: string;
includeFailureOutput?: boolean;
} = {}
)
| 83 | |
| 84 | // Thrown when a required executable is absent. Its message already carries the |
| 85 | // full install/verify guidance, so callers rethrow it as-is instead of wrapping |
| 86 | // it in a provider-access error (which would repeat the same instructions). |
| 87 | class MissingCommandError extends Error {} |
| 88 | |
| 89 | // `pnpm exec` exits non-zero, rather than failing with ENOENT, when the command |
| 90 | // exists but the workspace install does not provide the binary. |
| 91 | const PNPM_MISSING_WORKSPACE_VERCEL = /Command "vercel" not found/; |
| 92 | |
| 93 | function missingWorkspaceVercelMessage(): string { |
| 94 | return [ |
| 95 | 'The workspace does not provide the Vercel CLI.', |
| 96 | `Run \`pnpm install --frozen-lockfile\` in the checkout, then verify access with \`${VERCEL_COMMAND} whoami --scope kilocode --format=json\`.`, |
| 97 | ].join('\n'); |
| 98 | } |
| 99 | |
| 100 | export function run( |
| 101 | command: string, |
| 102 | args: string[], |
| 103 | options: { |
| 104 | cwd?: string; |
| 105 | env?: NodeJS.ProcessEnv; |
| 106 | input?: string; |
| 107 | includeFailureOutput?: boolean; |
| 108 | } = {} |
| 109 | ): string { |
| 110 | const result = spawnSync(command, args, { |
| 111 | cwd: options.cwd, |
| 112 | env: options.env, |
| 113 | input: options.input, |
| 114 | encoding: 'utf8', |
| 115 | stdio: ['pipe', 'pipe', 'pipe'], |
| 116 | maxBuffer: 10 * 1024 * 1024, |
| 117 | }); |
| 118 | if (errorCode(result.error) === 'ENOENT') { |
| 119 | const message = missingCommandMessage(command, args); |
| 120 | if (message) throw new MissingCommandError(message); |
| 121 | } |
| 122 | if ( |
no test coverage detected