diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2017-10-25 12:06:40 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2017-11-07 19:51:51 +0100 |
commit | 90a43906ab5ca8bdf154fb7644d70da9e3acdf00 (patch) | |
tree | 59b0e27656689f7ec94ccfc2c0d032d62f37d9ac /lib | |
parent | 6563e56aef5287646aa433bfe088a73a2bea855d (diff) | |
download | android-node-v8-90a43906ab5ca8bdf154fb7644d70da9e3acdf00.tar.gz android-node-v8-90a43906ab5ca8bdf154fb7644d70da9e3acdf00.tar.bz2 android-node-v8-90a43906ab5ca8bdf154fb7644d70da9e3acdf00.zip |
repl: show proxies as Proxy objects
Before this commit they transparently invoked their magic methods but
that sometimes throws confusing exceptions with misbehaving proxies.
This change is not wholly uncontroversial but we can always change the
default if necessary. Let's see how it goes.
Fixes: https://github.com/nodejs/node/issues/16483
PR-URL: https://github.com/nodejs/node/pull/16485
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/repl.js | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/repl.js b/lib/repl.js index 16e129641a..79acd217a4 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -100,7 +100,9 @@ function hasOwnProperty(obj, prop) { // Can overridden with custom print functions, such as `probe` or `eyes.js`. // This is the default "writer" value if none is passed in the REPL options. -exports.writer = util.inspect; +const writer = exports.writer = (obj) => util.inspect(obj, writer.options); +writer.options = + Object.assign(util.inspect.defaultOptions, { showProxy: true }); exports._builtinLibs = internalModule.builtinLibs; @@ -373,11 +375,10 @@ function REPLServer(prompt, } self.useColors = !!options.useColors; - if (self.useColors && self.writer === util.inspect) { + if (self.useColors && self.writer === writer) { // Turn on ANSI coloring. - self.writer = function(obj, showHidden, depth) { - return util.inspect(obj, showHidden, depth, true); - }; + self.writer = (obj) => util.inspect(obj, self.writer.options); + self.writer.options = Object.assign(writer.options, { colors: true }); } function filterInternalStackFrames(error, structuredStack) { |