@@ -13,6 +13,15 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1313const ROOT = path . resolve ( __dirname , '../..' ) ;
1414const MAIN = path . join ( ROOT , 'dist' , 'src' , 'main.js' ) ;
1515
16+ /**
17+ * Default stdout cap for `runCli`. `opencli list -f json` already weighs
18+ * ~1 MB at 1030 entries on v1.8.2 and grows with every new adapter. The
19+ * execFile default maxBuffer is 1 MB; past it stdout overflows and the
20+ * helper returns code 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER' instead of the
21+ * actual exit code.
22+ */
23+ const DEFAULT_MAX_BUFFER_BYTES = 16 * 1024 * 1024 ;
24+
1625export interface CliResult {
1726 stdout : string ;
1827 stderr : string ;
@@ -28,11 +37,7 @@ export async function runCli(
2837 opts : { timeout ?: number ; env ?: Record < string , string > ; maxBuffer ?: number } = { } ,
2938) : Promise < CliResult > {
3039 const timeout = opts . timeout ?? 30_000 ;
31- // `opencli list -f json` already weighs ~1 MB at 1030 entries on v1.8.2 and
32- // grows with every new adapter. The execFile default maxBuffer is 1 MB; past
33- // it stdout overflows and the helper returns code
34- // 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER' instead of the actual exit code.
35- const maxBuffer = opts . maxBuffer ?? 16 * 1024 * 1024 ;
40+ const maxBuffer = opts . maxBuffer ?? DEFAULT_MAX_BUFFER_BYTES ;
3641 try {
3742 const runtime = process . env . OPENCLI_TEST_RUNTIME || 'node' ;
3843 const { stdout, stderr } = await exec ( runtime , [ MAIN , ...args ] , {
0 commit comments