Files
renovate[bot] 1909c2ef22 build(deps): update dependency execa to v10 (main) (#45834)
* build(deps): update dependency execa to v10

| datasource | package | from  | to     |
| ---------- | ------- | ----- | ------ |
| npm        | execa   | 8.0.1 | 10.0.1 |

* fix(exec): adapt to execa v10 types and subprocess API

* fix(tools): type execa v10 results in hook exec and mkdocs

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: secustor <sebastian@poxhofer.at>
2026-09-25 09:00:52 +00:00

63 lines
1.5 KiB
TypeScript

import { execa } from 'execa';
import { formatCompletedLine, isTTY } from './tui.ts';
import type {
CheckResult,
ExecutionProgress,
ParallelCheck,
ProcessManager,
} from './types.ts';
export async function runCommand(
cmd: string,
args: string[],
processManager: ProcessManager,
env?: Record<string, string>,
): Promise<{ success: boolean; output: string }> {
const subprocess = execa(cmd, args, {
env,
cancelSignal: processManager.abortController.signal,
all: true,
reject: false,
});
processManager.subprocesses.add(subprocess);
const result = await subprocess;
processManager.subprocesses.delete(subprocess);
return { success: result.exitCode === 0, output: result.all ?? '' };
}
export async function runChecksParallel(
checks: ParallelCheck[],
resultOffset: number,
progress: ExecutionProgress,
processManager: ProcessManager,
): Promise<void> {
await Promise.all(
checks.map(async (check, idx) => {
progress.startedIndices.add(resultOffset + idx);
const start = Date.now();
const { success, output } = await runCommand(
check.cmd,
check.args,
processManager,
check.env,
);
const duration = (Date.now() - start) / 1000;
const result: CheckResult = {
name: check.name,
success,
duration,
output,
};
progress.results[resultOffset + idx] = { result };
if (!isTTY) {
console.log(
formatCompletedLine(result.name, result.success, result.duration),
);
}
}),
);
}