@@ -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' ) ,
@@ -318,7 +315,7 @@ function parseArgv(args) {
318
315
process . _debugProcess ( pid ) ;
319
316
} catch ( e ) {
320
317
if ( e . code === 'ESRCH' ) {
321
- console . error ( `Target process: ${ pid } doesn't exist.` ) ;
318
+ process . stderr . write ( `Target process: ${ pid } doesn't exist.\n ` ) ;
322
319
process . exit ( kGenericUserError ) ;
323
320
}
324
321
throw e ;
@@ -338,10 +335,10 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
338
335
if ( argv . length < 1 ) {
339
336
const invokedAs = `${ process . argv0 } ${ process . argv [ 1 ] } ` ;
340
337
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 ` ) ;
345
342
// TODO(joyeecheung): should be kInvalidCommandLineArgument.
346
343
process . exit ( kGenericUserError ) ;
347
344
}
@@ -353,12 +350,12 @@ function startInspect(argv = ArrayPrototypeSlice(process.argv, 2),
353
350
354
351
function handleUnexpectedError ( e ) {
355
352
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` ) ;
360
356
} else {
361
- console . error ( e . message ) ;
357
+ process . stderr . write ( e . message ) ;
358
+ process . stderr . write ( '\n' ) ;
362
359
}
363
360
if ( inspector . child ) inspector . child . kill ( ) ;
364
361
process . exit ( kGenericUserError ) ;
0 commit comments