Files
rea/src/process/ExecFileOutput.ts
T
morluto fc4a9a0592 fix(artifacts): preserve reader failure diagnostics (#987)
* fix(artifacts): preserve filesystem and DMG diagnostics

* fix(artifacts): classify DMG verification failures

* fix(artifacts): distinguish inaccessible disk images

* fix(artifacts): classify damaged image checksums
2026-10-07 23:58:07 +08:00

37 lines
987 B
TypeScript

import {
execFile,
type ExecFileOptionsWithStringEncoding,
} from "node:child_process";
type ExecFileOutputOptions = Omit<
ExecFileOptionsWithStringEncoding,
"encoding" | "maxBuffer"
> & { readonly maxBuffer?: number };
/** Run a shell-free command while capturing its complete UTF-8 output. */
export const execFileOutput = (
command: string,
arguments_: readonly string[],
options: ExecFileOutputOptions = {},
): Promise<{ readonly stdout: string; readonly stderr: string }> =>
new Promise((resolve, reject) => {
execFile(
command,
[...arguments_],
{
...options,
encoding: "utf8",
maxBuffer: options.maxBuffer ?? Number.POSITIVE_INFINITY,
},
(error, stdout, stderr) => {
if (error !== null) {
Reflect.set(error, "stdout", stdout);
Reflect.set(error, "stderr", stderr);
reject(error);
return;
}
resolve({ stdout, stderr });
},
);
});