diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-01-19 15:34:00 +0100 |
---|---|---|
committer | Daniel Bevenius <daniel.bevenius@gmail.com> | 2019-03-08 04:44:56 +0100 |
commit | 82f882140120f4ce074fe0de01e380cb3c7c9fc3 (patch) | |
tree | 0ac564d4e68c0564b0d185b1e2c7ad5b2eb77543 /test/parallel/test-repl-inspect-defaults.js | |
parent | 6de88015bbeb9cd9c6442399db6e8838abd8bec2 (diff) | |
download | android-node-v8-82f882140120f4ce074fe0de01e380cb3c7c9fc3.tar.gz android-node-v8-82f882140120f4ce074fe0de01e380cb3c7c9fc3.tar.bz2 android-node-v8-82f882140120f4ce074fe0de01e380cb3c7c9fc3.zip |
repl: add replDefaults to customize the writer
So far it was not possible to modify the inspection defaults used by
the REPL from the running instance itself. This introduces a new
property on `util.inspect` which is only used inside the REPL and which
allows to modify the used inspection defaults at any point of time.
PR-URL: https://github.com/nodejs/node/pull/26375
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-repl-inspect-defaults.js')
-rw-r--r-- | test/parallel/test-repl-inspect-defaults.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/parallel/test-repl-inspect-defaults.js b/test/parallel/test-repl-inspect-defaults.js new file mode 100644 index 0000000000..a73bc792fe --- /dev/null +++ b/test/parallel/test-repl-inspect-defaults.js @@ -0,0 +1,29 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cp = require('child_process'); +const child = cp.spawn(process.execPath, ['-i']); +let output = ''; + +child.stdout.setEncoding('utf8'); +child.stdout.on('data', (data) => { + output += data; +}); + +child.on('exit', common.mustCall(() => { + const results = output.replace(/^> /mg, '').split('\n'); + assert.deepStrictEqual( + results, + [ + '[ 42, 23 ]', + '1', + '[ 42, ... 1 more item ]', + '' + ] + ); +})); + +child.stdin.write('[ 42, 23 ]\n'); +child.stdin.write('util.inspect.replDefaults.maxArrayLength = 1\n'); +child.stdin.write('[ 42, 23 ]\n'); +child.stdin.end(); |