Files
scriptc/tests/corpus/2912-execfile-callback-options.ts
Chris Tate e334ae444e feat(child_process): support inline execFile callback options (#387)
* feat(child_process): lower UTF-8 execFile callback options

* test(ts7): record execFile callback options fixture order
2026-09-23 00:13:44 -05:00

24 lines
946 B
TypeScript

// The inline utf8/maxBuffer callback shape preserves concurrent execution,
// streams and error-first result on both successful and failed children.
import { execFile } from "node:child_process";
const child = execFile(
"/bin/sh",
["-c", "printf out; printf note >&2"],
{ encoding: "utf8", maxBuffer: 64 * 1024 * 1024 },
(error: Error | null, stdout, stderr) => {
console.log("ok", error === null, JSON.stringify(stdout), JSON.stringify(stderr));
execFile(
"/bin/sh",
["-c", "printf partial; printf failed >&2; exit 3"],
{ encoding: "utf8", maxBuffer: 67108864 },
(failed: Error | null, failedOut, failedErr) => {
console.log("failed", failed !== null, JSON.stringify(failedOut), JSON.stringify(failedErr));
console.log("error", failed === null ? "" : failed.message.includes("exit 3"));
},
);
},
);
console.log("returned", child.pid !== undefined);
console.log("scheduled");