File tree 2 files changed +18
-5
lines changed
2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -100,7 +100,9 @@ function hasOwnProperty(obj, prop) {
100
100
101
101
// Can overridden with custom print functions, such as `probe` or `eyes.js`.
102
102
// This is the default "writer" value if none is passed in the REPL options.
103
- exports . writer = util . inspect ;
103
+ const writer = exports . writer = ( obj ) => util . inspect ( obj , writer . options ) ;
104
+ writer . options =
105
+ Object . assign ( util . inspect . defaultOptions , { showProxy : true } ) ;
104
106
105
107
exports . _builtinLibs = internalModule . builtinLibs ;
106
108
@@ -370,11 +372,10 @@ function REPLServer(prompt,
370
372
}
371
373
self . useColors = ! ! options . useColors ;
372
374
373
- if ( self . useColors && self . writer === util . inspect ) {
375
+ if ( self . useColors && self . writer === writer ) {
374
376
// Turn on ANSI coloring.
375
- self . writer = function ( obj , showHidden , depth ) {
376
- return util . inspect ( obj , showHidden , depth , true ) ;
377
- } ;
377
+ self . writer = ( obj ) => util . inspect ( obj , self . writer . options ) ;
378
+ self . writer . options = Object . assign ( writer . options , { colors : true } ) ;
378
379
}
379
380
380
381
function filterInternalStackFrames ( error , structuredStack ) {
Original file line number Diff line number Diff line change @@ -412,6 +412,18 @@ function error_test() {
412
412
expect : `${ prompt_multiline } ${ prompt_multiline } undefined\n${ prompt_unix } `
413
413
} ,
414
414
415
+ // https://github.com/nodejs/node/issues/16483
416
+ {
417
+ client : client_unix , send : 'new Proxy({x:42}, {get(){throw null}});' ,
418
+ expect : `Proxy [ { x: 42 }, { get: [Function: get] } ]\n${ prompt_unix } `
419
+ } ,
420
+ {
421
+ client : client_unix ,
422
+ send : 'repl.writer.options.showProxy = false, new Proxy({x:42}, {});' ,
423
+ expect : `{ x: 42 }\n${ prompt_unix } `
424
+ } ,
425
+
426
+
415
427
// Newline within template string maintains whitespace.
416
428
{ client : client_unix , send : '`foo \n`' ,
417
429
expect : `${ prompt_multiline } 'foo \\n'\n${ prompt_unix } ` } ,
You can’t perform that action at this time.
0 commit comments