process: do not truncate long strings in --print

Fixes: https://github.com/nodejs/node/issues/61337
PR-URL: https://github.com/nodejs/node/pull/61497
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Mohamed Akram authored and Juan José Arboleda committed 2026-07-19 17:30:36 -05:00
1 parent dccfee1cd0
commit 27fb167f77
2 files changed
+12 -2

No files matched your search

+6 -2
View File
@@ -450,8 +450,12 @@ function runScriptInContext(name, body, breakFirstLine, print, module, baseUrl,
if (print) {
const { log } = require('internal/console/global');
process.on('exit', () => {
log(result);
const printResult = () => log(result);
process.on('exit', printResult);
process.once('beforeExit', () => {
printResult();
process.off('exit', printResult);
});
}
if (origModule !== undefined)
+6
View File
@@ -115,6 +115,12 @@ child.exec(...common.escapePOSIXShell`"${process.execPath}" -p "\\-42"`, common.
assert.strictEqual(stderr, '');
}));
// Long output should not be truncated.
child.exec(...common.escapePOSIXShell`"${process.execPath}" -p "'1'.repeat(1e5)"`, common.mustSucceed((stdout, stderr) => {
assert.strictEqual(stdout, `${'1'.repeat(1e5)}\n`);
assert.strictEqual(stderr, '');
}));
child.exec(...common.escapePOSIXShell`"${process.execPath}" --use-strict -p process.execArgv`,
common.mustSucceed((stdout, stderr) => {
assert.strictEqual(