Skip to content

Commit 27fb167

Browse files
mohd-akramjuanarbol
authored andcommitted
process: do not truncate long strings in --print
Fixes: #61337 PR-URL: #61497 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent dccfee1 commit 27fb167

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

lib/internal/process/execution.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,8 +450,12 @@ function runScriptInContext(name, body, breakFirstLine, print, module, baseUrl,
450450
if (print) {
451451
const { log } = require('internal/console/global');
452452

453-
process.on('exit', () => {
454-
log(result);
453+
const printResult = () => log(result);
454+
455+
process.on('exit', printResult);
456+
process.once('beforeExit', () => {
457+
printResult();
458+
process.off('exit', printResult);
455459
});
456460
}
457461
if (origModule !== undefined)

test/parallel/test-cli-eval.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ child.exec(...common.escapePOSIXShell`"${process.execPath}" -p "\\-42"`, common.
115115
assert.strictEqual(stderr, '');
116116
}));
117117

118+
// Long output should not be truncated.
119+
child.exec(...common.escapePOSIXShell`"${process.execPath}" -p "'1'.repeat(1e5)"`, common.mustSucceed((stdout, stderr) => {
120+
assert.strictEqual(stdout, `${'1'.repeat(1e5)}\n`);
121+
assert.strictEqual(stderr, '');
122+
}));
123+
118124
child.exec(...common.escapePOSIXShell`"${process.execPath}" --use-strict -p process.execArgv`,
119125
common.mustSucceed((stdout, stderr) => {
120126
assert.strictEqual(

0 commit comments

Comments
 (0)