@@ -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' ) ,
@@ -312,7 +309,7 @@ function parseArgv(args) {
312309 process . _debugProcess ( pid ) ;
313310 } catch ( e ) {
314311 if ( e . code === 'ESRCH' ) {
315- console . error ( `Target process: ${ pid } doesn't exist.` ) ;
312+ process . stderr . write ( `Target process: ${ pid } doesn't exist.\n ` ) ;
316313 process . exit ( 1 ) ;
317314 }
318315 throw e ;
@@ -332,10 +329,10 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
332329 if ( argv . length < 1 ) {
333330 const invokedAs = `${ process . argv0 } ${ process . argv [ 1 ] } ` ;
334331
335- console . error ( `Usage: ${ invokedAs } script.js` ) ;
336- console . error ( ` ${ invokedAs } <host>:<port>` ) ;
337- console . error ( ` ${ invokedAs } --port=<port>` ) ;
338- console . error ( ` ${ invokedAs } -p <pid>` ) ;
332+ process . stderr . write ( `Usage: ${ invokedAs } script.js\n` +
333+ ` ${ invokedAs } <host>:<port>\n` +
334+ ` ${ invokedAs } --port=<port>\n` +
335+ ` ${ invokedAs } -p <pid>\n ` ) ;
339336 process . exit ( 1 ) ;
340337 }
341338
@@ -346,12 +343,12 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
346343
347344 function handleUnexpectedError ( e ) {
348345 if ( e . code !== 'ERR_DEBUGGER_STARTUP_ERROR' ) {
349- console . error ( 'There was an internal error in Node.js. ' +
350- 'Please report this bug.' ) ;
351- console . error ( e . message ) ;
352- console . error ( e . stack ) ;
346+ process . stderr . write ( 'There was an internal error in Node.js. ' +
347+ 'Please report this bug.\n' +
348+ `${ e . message } \n${ e . stack } \n` ) ;
353349 } else {
354- console . error ( e . message ) ;
350+ process . stderr . write ( e . message ) ;
351+ process . stderr . write ( '\n' ) ;
355352 }
356353 if ( inspector . child ) inspector . child . kill ( ) ;
357354 process . exit ( 1 ) ;
0 commit comments