diff --git a/lib/internal/util/inspect.js b/lib/internal/util/inspect.js index 998b15274005a8..3e93a41795c8d8 100644 --- a/lib/internal/util/inspect.js +++ b/lib/internal/util/inspect.js @@ -257,7 +257,6 @@ ObjectDefineProperty(inspect, 'defaultOptions', { } }); -// TODO(BridgeAR): Add further color codes. // http://en.wikipedia.org/wiki/ANSI_escape_code#graphics inspect.colors = ObjectAssign(ObjectCreate(null), { bold: [1, 22], @@ -272,8 +271,7 @@ inspect.colors = ObjectAssign(ObjectCreate(null), { green: [32, 39], magenta: [35, 39], red: [31, 39], - yellow: [33, 39], - brightRed: [91, 39] + yellow: [33, 39] }); // Don't use 'blue' not visible on cmd.exe diff --git a/lib/repl.js b/lib/repl.js index 1328c1bfe189d7..9a536e9165ea77 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -550,14 +550,9 @@ function REPLServer(prompt, errStack = self.writer(e); } const lines = errStack.split(/(?<=\n)/); - let colors = ''; - if (options.useColors) { - colors = `\u001b[${inspect.colors.brightRed[0]}m` + - `\u001b[${inspect.colors.bold[0]}m`; - } let matched = false; - errStack = colors; + errStack = ''; for (const line of lines) { if (!matched && /^\[?([A-Z][a-z0-9_]*)*Error/.test(line)) { errStack += writer.options.breakLength >= line.length ? @@ -570,16 +565,10 @@ function REPLServer(prompt, } if (!matched) { const ln = lines.length === 1 ? ' ' : ':\n'; - // eslint-disable-next-line no-control-regex - errStack = errStack.replace(/\u001b\[[0-9]{1,3}m/g, ''); - errStack = `${colors}Uncaught${ln}${errStack}`; + errStack = `Uncaught${ln}${errStack}`; } // Normalize line endings. errStack += errStack.endsWith('\n') ? '' : '\n'; - if (options.useColors) { - errStack += `\u001b[${inspect.colors.brightRed[1]}m` + - `\u001b[${inspect.colors.bold[1]}m`; - } top.outputStream.write(errStack); top.clearBufferedCommand(); top.lines.level = []; diff --git a/test/parallel/test-repl-pretty-stack.js b/test/parallel/test-repl-pretty-stack.js index a528cdefaf4390..456e866b7b20f9 100644 --- a/test/parallel/test-repl-pretty-stack.js +++ b/test/parallel/test-repl-pretty-stack.js @@ -58,9 +58,8 @@ const tests = [ { command: '(() => { const err = Error(\'Whoops!\'); ' + 'err.foo = \'bar\'; throw err; })()', - expected: '\u001b[91m\u001b[1m' + - 'Uncaught Error: Whoops!\n at repl:*:* {\n foo: ' + - "\u001b[32m'bar'\u001b[39m\n}\n\u001b[39m\u001b[22m", + expected: 'Uncaught Error: Whoops!\n at repl:*:* {\n foo: ' + + "\u001b[32m'bar'\u001b[39m\n}\n", useColors: true }, { diff --git a/test/parallel/test-repl-uncaught-exception.js b/test/parallel/test-repl-uncaught-exception.js index 063a2a0e7c67d3..28e62dff22bf3a 100644 --- a/test/parallel/test-repl-uncaught-exception.js +++ b/test/parallel/test-repl-uncaught-exception.js @@ -40,16 +40,12 @@ const tests = [ { useColors: true, command: 'x', - expected: '\u001b[91m\u001b[1m' + - 'Uncaught ReferenceError: x is not defined\n' + - '\u001b[39m\u001b[22m' + expected: 'Uncaught ReferenceError: x is not defined\n' }, { useColors: true, command: 'throw { foo: "test" }', - expected: '\u001b[91m\u001b[1m' + - "Uncaught { foo: 'test' }\n" + - '\u001b[39m\u001b[22m' + expected: "Uncaught { foo: \x1B[32m'test'\x1B[39m }\n" }, { command: 'process.on("uncaughtException", () => console.log("Foobar"));\n',