Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2019-04-18 07:25:57 +0300
committerJoyee Cheung <joyeec9h3@gmail.com>2019-04-28 09:46:23 +0300
commit2b24ffae2240163a74ae11e49ee198e98abb07dc (patch)
treef6abfd48eba3b21e722dd96e0ede245d50d28035 /lib/internal/main
parent31b3dd28429df7ea7ebc84bdfaf8d9eb9e417b41 (diff)
lib: print to stdout/stderr directly instead of using console
This patch adds an internal function that prints to stdout or stderr by directly writing to the known file descriptor, and uses it internally in common cases to avoid the overhead of the console implementation. PR-URL: https://github.com/nodejs/node/pull/27320 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/main')
-rw-r--r--lib/internal/main/repl.js10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/internal/main/repl.js b/lib/internal/main/repl.js
index 980893f9c34..58afb2be987 100644
--- a/lib/internal/main/repl.js
+++ b/lib/internal/main/repl.js
@@ -11,7 +11,7 @@ const {
evalScript
} = require('internal/process/execution');
-const console = require('internal/console/global');
+const { print, kStderr, kStdout } = require('internal/util/print');
const { getOptionValue } = require('internal/options');
@@ -21,14 +21,12 @@ markBootstrapComplete();
// --input-type flag not supported in REPL
if (getOptionValue('--input-type')) {
- // If we can't write to stderr, we'd like to make this a noop,
- // so use console.error.
- console.error('Cannot specify --input-type for REPL');
+ print(kStderr, 'Cannot specify --input-type for REPL');
process.exit(1);
}
-console.log(`Welcome to Node.js ${process.version}.\n` +
- 'Type ".help" for more information.');
+print(kStdout, `Welcome to Node.js ${process.version}.\n` +
+ 'Type ".help" for more information.');
const cliRepl = require('internal/repl');
cliRepl.createInternalRepl(process.env, (err, repl) => {