@@ -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' ) ,
@@ -318,7 +315,7 @@ function parseArgv(args) {
318315 process . _debugProcess ( pid ) ;
319316 } catch ( e ) {
320317 if ( e . code === 'ESRCH' ) {
321- console . error ( `Target process: ${ pid } doesn't exist.` ) ;
318+ process . stderr . write ( `Target process: ${ pid } doesn't exist.\n ` ) ;
322319 process . exit ( kGenericUserError ) ;
323320 }
324321 throw e ;
@@ -338,10 +335,10 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
338335 if ( argv . length < 1 ) {
339336 const invokedAs = `${ process . argv0 } ${ process . argv [ 1 ] } ` ;
340337
341- console . error ( `Usage: ${ invokedAs } script.js` ) ;
342- console . error ( ` ${ invokedAs } <host>:<port>` ) ;
343- console . error ( ` ${ invokedAs } --port=<port>` ) ;
344- console . error ( ` ${ invokedAs } -p <pid>` ) ;
338+ process . stderr . write ( `Usage: ${ invokedAs } script.js\n` +
339+ ` ${ invokedAs } <host>:<port>\n` +
340+ ` ${ invokedAs } --port=<port>\n` +
341+ ` ${ invokedAs } -p <pid>\n ` ) ;
345342 // TODO(joyeecheung): should be kInvalidCommandLineArgument.
346343 process . exit ( kGenericUserError ) ;
347344 }
@@ -353,12 +350,12 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
353350
354351 function handleUnexpectedError ( e ) {
355352 if ( e . code !== 'ERR_DEBUGGER_STARTUP_ERROR' ) {
356- console . error ( 'There was an internal error in Node.js. ' +
357- 'Please report this bug.' ) ;
358- console . error ( e . message ) ;
359- console . error ( e . stack ) ;
353+ process . stderr . write ( 'There was an internal error in Node.js. ' +
354+ 'Please report this bug.\n' +
355+ `${ e . message } \n${ e . stack } \n` ) ;
360356 } else {
361- console . error ( e . message ) ;
357+ process . stderr . write ( e . message ) ;
358+ process . stderr . write ( '\n' ) ;
362359 }
363360 if ( inspector . child ) inspector . child . kill ( ) ;
364361 process . exit ( kGenericUserError ) ;
0 commit comments