lib: end --eval crypto wrapper code with a newline

Assisted-by: Claude Code
Signed-off-by: lazerg <lazerg2@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67162
Fixes: https://github.com/nodejs/node/issues/67159
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
Lazizbek Ergashev authored and Antoine du Hamel committed 2026-11-25 17:59:18 +01:00
1 parent 4d9a7526b0
commit bc94c91ad0
2 files changed
+9 -1

No files matched your search

+1 -1
View File
@@ -70,7 +70,7 @@ if (inputType === 'module') {
evalFunction('[eval]',
shouldDefineCrypto ? (
print ? `let crypto=require("node:crypto");{${code}}` : `(crypto=>{{${code}}})(require('node:crypto'))`
print ? `let crypto=require("node:crypto");{${code}\n}` : `(crypto=>{{${code}\n}})(require('node:crypto'))`
) : code,
getOptionValue('--inspect-brk'),
print,
+8
View File
@@ -329,6 +329,14 @@ if (common.hasCrypto) {
common.mustSucceed((stdout) => {
assert.match(stdout, /[0-9a-f]{32}/i);
}));
child.execFile(process.execPath, ['-e', 'console.log(typeof crypto.randomBytes) // comment'],
common.mustSucceed((stdout) => {
assert.strictEqual(stdout, 'function\n');
}));
child.execFile(process.execPath, ['-p', 'typeof crypto.randomBytes // comment'],
common.mustSucceed((stdout) => {
assert.strictEqual(stdout, 'function\n');
}));
}
// Assert that overriding crypto works.
child.exec(