@@ -32,9 +32,6 @@ const {
3232 AbortController,
3333} = require ( 'internal/abort_controller' ) ;
3434
35- // TODO(aduh95): remove console calls
36- const console = require ( 'internal/console/global' ) ;
37-
3835const { 0 : InspectClient , 1 : createRepl } =
3936 [
4037 require ( 'internal/debugger/inspect_client' ) ,
@@ -319,7 +316,7 @@ function parseArgv(args) {
319316 process . _debugProcess ( pid ) ;
320317 } catch ( e ) {
321318 if ( e . code === 'ESRCH' ) {
322- console . error ( `Target process: ${ pid } doesn't exist.` ) ;
319+ process . stderr . write ( `Target process: ${ pid } doesn't exist.\n ` ) ;
323320 process . exit ( kGenericUserError ) ;
324321 }
325322 throw e ;
@@ -339,10 +336,10 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
339336 if ( argv . length < 1 ) {
340337 const invokedAs = `${ process . argv0 } ${ process . argv [ 1 ] } ` ;
341338
342- console . error ( `Usage: ${ invokedAs } script.js` ) ;
343- console . error ( ` ${ invokedAs } <host>:<port>` ) ;
344- console . error ( ` ${ invokedAs } --port=<port>` ) ;
345- console . error ( ` ${ invokedAs } -p <pid>` ) ;
339+ process . stderr . write ( `Usage: ${ invokedAs } script.js\n` +
340+ ` ${ invokedAs } <host>:<port>\n` +
341+ ` ${ invokedAs } --port=<port>\n` +
342+ ` ${ invokedAs } -p <pid>\n ` ) ;
346343 // TODO(joyeecheung): should be kInvalidCommandLineArgument.
347344 process . exit ( kGenericUserError ) ;
348345 }
@@ -354,12 +351,12 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
354351
355352 function handleUnexpectedError ( e ) {
356353 if ( e . code !== 'ERR_DEBUGGER_STARTUP_ERROR' ) {
357- console . error ( 'There was an internal error in Node.js. ' +
358- 'Please report this bug.' ) ;
359- console . error ( e . message ) ;
360- console . error ( e . stack ) ;
354+ process . stderr . write ( 'There was an internal error in Node.js. ' +
355+ 'Please report this bug.\n' +
356+ `${ e . message } \n${ e . stack } \n` ) ;
361357 } else {
362- console . error ( e . message ) ;
358+ process . stderr . write ( e . message ) ;
359+ process . stderr . write ( '\n' ) ;
363360 }
364361 if ( inspector . child ) inspector . child . kill ( ) ;
365362 process . exit ( kGenericUserError ) ;
0 commit comments