mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
The `Object.assign()` calls introduced in commit 90a4390 ("repl: show
proxies as Proxy objects") mutated their first argument, causing the
`{ colors: true }` option from the REPL to leak over into the global
`util.inspect.defaultOptions` object.
Refs: https://github.com/nodejs/node/pull/16485#issuecomment-350428638
PR-URL: https://github.com/nodejs/node/pull/17565
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
32 lines
992 B
JavaScript
32 lines
992 B
JavaScript
/* eslint-disable quotes */
|
|
'use strict';
|
|
require('../common');
|
|
const { Duplex } = require('stream');
|
|
const { inspect } = require('util');
|
|
const { strictEqual } = require('assert');
|
|
const { REPLServer } = require('repl');
|
|
|
|
let output = '';
|
|
|
|
const inout = new Duplex({ decodeStrings: false });
|
|
inout._read = function() {
|
|
this.push('util.inspect("string")\n');
|
|
this.push(null);
|
|
};
|
|
inout._write = function(s, _, cb) {
|
|
output += s;
|
|
cb();
|
|
};
|
|
|
|
const repl = new REPLServer({ input: inout, output: inout, useColors: true });
|
|
|
|
process.on('exit', function() {
|
|
// https://github.com/nodejs/node/pull/16485#issuecomment-350428638
|
|
// The color setting of the REPL should not have leaked over into
|
|
// the color setting of `util.inspect.defaultOptions`.
|
|
strictEqual(output.includes(`'\\'string\\''`), true);
|
|
strictEqual(output.includes(`'\u001b[32m\\'string\\'\u001b[39m'`), false);
|
|
strictEqual(inspect.defaultOptions.colors, false);
|
|
strictEqual(repl.writer.options.colors, true);
|
|
});
|