@@ -32,9 +32,6 @@ const {
32
32
AbortController,
33
33
} = require ( 'internal/abort_controller' ) ;
34
34
35
- // TODO(aduh95): remove console calls
36
- const console = require ( 'internal/console/global' ) ;
37
-
38
35
const { 0 : InspectClient , 1 : createRepl } =
39
36
[
40
37
require ( 'internal/debugger/inspect_client' ) ,
@@ -319,7 +316,7 @@ function parseArgv(args) {
319
316
process . _debugProcess ( pid ) ;
320
317
} catch ( e ) {
321
318
if ( e . code === 'ESRCH' ) {
322
- console . error ( `Target process: ${ pid } doesn't exist.` ) ;
319
+ process . stderr . write ( `Target process: ${ pid } doesn't exist.\n ` ) ;
323
320
process . exit ( kGenericUserError ) ;
324
321
}
325
322
throw e ;
@@ -339,10 +336,10 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
339
336
if ( argv . length < 1 ) {
340
337
const invokedAs = `${ process . argv0 } ${ process . argv [ 1 ] } ` ;
341
338
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 ` ) ;
346
343
// TODO(joyeecheung): should be kInvalidCommandLineArgument.
347
344
process . exit ( kGenericUserError ) ;
348
345
}
@@ -354,12 +351,12 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
354
351
355
352
function handleUnexpectedError ( e ) {
356
353
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` ) ;
361
357
} else {
362
- console . error ( e . message ) ;
358
+ process . stderr . write ( e . message ) ;
359
+ process . stderr . write ( '\n' ) ;
363
360
}
364
361
if ( inspector . child ) inspector . child . kill ( ) ;
365
362
process . exit ( kGenericUserError ) ;
0 commit comments