diff --git a/packages/turbo-ignore/src/cli.ts b/packages/turbo-ignore/src/cli.ts index bb0a88dd005d3..4b17b284db029 100755 --- a/packages/turbo-ignore/src/cli.ts +++ b/packages/turbo-ignore/src/cli.ts @@ -30,6 +30,12 @@ turboIgnoreCli "The directory to run in (default: cwd)" ) ) + .addOption( + new Option( + "-b, --max-buffer ", + "maxBuffer for the child process in KB (default: 1024 KB)" + ).argParser((val) => parseInt(val, 10) * 1024) + ) .version(cliPkg.version, "-v, --version", "Output the current version") .helpOption("-h, --help", "Display help for command") .showHelpAfterError(false) diff --git a/packages/turbo-ignore/src/ignore.ts b/packages/turbo-ignore/src/ignore.ts index 764ec8e8010af..0ad049f10fddd 100644 --- a/packages/turbo-ignore/src/ignore.ts +++ b/packages/turbo-ignore/src/ignore.ts @@ -95,50 +95,53 @@ export function turboIgnore( // Build, and execute the command const command = `npx turbo run ${task} --filter=${workspace}...[${comparison.ref}] --dry=json`; info(`Analyzing results of \`${command}\``); - exec( - command, - { - cwd: root, - }, - (err, stdout) => { - if (err) { - const { level, code, message } = shouldWarn({ err: err.message }); - if (level === "warn") { - warn(message); - } else { - error(`${code}: ${err.message}`); - } - return continueBuild(); + + const execOptions: { cwd: string; maxBuffer?: number } = { + cwd: root, + }; + + if (opts.maxBuffer) { + execOptions.maxBuffer = opts.maxBuffer; + } + + exec(command, execOptions, (err, stdout) => { + if (err) { + const { level, code, message } = shouldWarn({ err: err.message }); + if (level === "warn") { + warn(message); + } else { + error(`${code}: ${err.message}`); } + return continueBuild(); + } - try { - const parsed = JSON.parse(stdout) as DryRun | null; - if (parsed === null) { - error(`Failed to parse JSON output from \`${command}\`.`); - return continueBuild(); - } - const { packages } = parsed; - if (packages.length > 0) { - if (packages.length === 1) { - info(`This commit affects "${workspace}"`); - } else { - // subtract 1 because the first package is the workspace itself - info( - `This commit affects "${workspace}" and ${packages.length - 1} ${ - packages.length - 1 === 1 ? "dependency" : "dependencies" - } (${packages.slice(1).join(", ")})` - ); - } - - return continueBuild(); - } - info(`This project and its dependencies are not affected`); - return ignoreBuild(); - } catch (e) { + try { + const parsed = JSON.parse(stdout) as DryRun | null; + if (parsed === null) { error(`Failed to parse JSON output from \`${command}\`.`); - error(e); return continueBuild(); } + const { packages } = parsed; + if (packages.length > 0) { + if (packages.length === 1) { + info(`This commit affects "${workspace}"`); + } else { + // subtract 1 because the first package is the workspace itself + info( + `This commit affects "${workspace}" and ${packages.length - 1} ${ + packages.length - 1 === 1 ? "dependency" : "dependencies" + } (${packages.slice(1).join(", ")})` + ); + } + + return continueBuild(); + } + info(`This project and its dependencies are not affected`); + return ignoreBuild(); + } catch (e) { + error(`Failed to parse JSON output from \`${command}\`.`); + error(e); + return continueBuild(); } - ); + }); } diff --git a/packages/turbo-ignore/src/types.ts b/packages/turbo-ignore/src/types.ts index 34ad4e759ddfc..1ff1b1d24da70 100644 --- a/packages/turbo-ignore/src/types.ts +++ b/packages/turbo-ignore/src/types.ts @@ -23,4 +23,6 @@ export interface TurboIgnoreOptions { task?: string; // A ref/head to compare against if no previously deployed SHA is available fallback?: string; + // The maxBuffer for the child process in KB + maxBuffer?: number; }