diff options
Diffstat (limited to 'lib/internal/process')
-rw-r--r-- | lib/internal/process/execution.js | 8 | ||||
-rw-r--r-- | lib/internal/process/warning.js | 10 |
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/internal/process/execution.js b/lib/internal/process/execution.js index 7b651ba5d1..86f3ee5b5a 100644 --- a/lib/internal/process/execution.js +++ b/lib/internal/process/execution.js @@ -36,17 +36,18 @@ function tryGetCwd() { } function evalModule(source) { + const { log, error } = require('internal/console/global'); const { decorateErrorStack } = require('internal/util'); const asyncESM = require('internal/process/esm_loader'); asyncESM.loaderPromise.then(async (loader) => { const { result } = await loader.eval(source); if (require('internal/options').getOptionValue('--print')) { - console.log(result); + log(result); } }) .catch((e) => { decorateErrorStack(e); - console.error(e); + error(e); process.exit(1); }); // Handle any nextTicks added in the first tick of the program. @@ -79,7 +80,8 @@ function evalScript(name, body, breakFirstLine) { });\n`; const result = module._compile(script, `${name}-wrapper`); if (require('internal/options').getOptionValue('--print')) { - console.log(result); + const { log } = require('internal/console/global'); + log(result); } // Handle any nextTicks added in the first tick of the program. process._tickCallback(); diff --git a/lib/internal/process/warning.js b/lib/internal/process/warning.js index 71a2c4fa3a..3ad3d4b9fb 100644 --- a/lib/internal/process/warning.js +++ b/lib/internal/process/warning.js @@ -17,10 +17,14 @@ function lazyOption() { return warningFile; } +// If we can't write to stderr, we'd like to make this a noop, +// so use console.error. +let error; function writeOut(message) { - if (console && typeof console.error === 'function') - return console.error(message); - process._rawDebug(message); + if (!error) { + error = require('internal/console/global').error; + } + error(message); } function writeToFile(message) { |