fix: make cli check lightweight by default
This commit is contained in:
@@ -7,20 +7,26 @@ export interface CommandResult {
|
||||
exitCode: number | null;
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
signal: NodeJS.Signals | null;
|
||||
timedOut: boolean;
|
||||
}
|
||||
|
||||
export function runCommand(command: string[], cwd: string): CommandResult {
|
||||
export function runCommand(command: string[], cwd: string, options: { timeoutMs?: number } = {}): CommandResult {
|
||||
const result = spawnSync(command[0], command.slice(1), {
|
||||
cwd,
|
||||
encoding: "utf8",
|
||||
maxBuffer: 1024 * 1024 * 8,
|
||||
timeout: options.timeoutMs,
|
||||
});
|
||||
const error = result.error as (Error & { code?: string }) | undefined;
|
||||
return {
|
||||
command,
|
||||
cwd,
|
||||
exitCode: result.status,
|
||||
stdout: result.stdout ?? "",
|
||||
stderr: result.stderr ?? result.error?.message ?? "",
|
||||
stderr: result.stderr ?? error?.message ?? "",
|
||||
signal: result.signal,
|
||||
timedOut: error?.code === "ETIMEDOUT",
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user