Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1dcc5ee

Browse filesBrowse files
avivkellertargos
authored andcommitted
Revert "console: colorize console error and warn"
This reverts commit a833c9e. PR-URL: #54677 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent 60a35ed commit 1dcc5ee
Copy full SHA for 1dcc5ee

File tree

Expand file treeCollapse file tree

5 files changed

+12
-27
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+12
-27
lines changed
Open diff view settings
Collapse file

‎lib/internal/console/constructor.js‎

Copy file name to clipboardExpand all lines: lib/internal/console/constructor.js
+5-20Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const {
88
ArrayIsArray,
99
ArrayPrototypeForEach,
1010
ArrayPrototypePush,
11-
ArrayPrototypeSome,
1211
ArrayPrototypeUnshift,
1312
Boolean,
1413
ErrorCaptureStackTrace,
@@ -60,7 +59,6 @@ const {
6059
const {
6160
CHAR_UPPERCASE_C: kTraceCount,
6261
} = require('internal/constants');
63-
const { styleText } = require('util');
6462
const kCounts = Symbol('counts');
6563
const { time, timeLog, timeEnd, kNone } = require('internal/util/debuglog');
6664

@@ -264,7 +262,7 @@ ObjectDefineProperties(Console.prototype, {
264262
[kWriteToConsole]: {
265263
__proto__: null,
266264
...consolePropAttributes,
267-
value: function(streamSymbol, string, color = '') {
265+
value: function(streamSymbol, string) {
268266
const ignoreErrors = this._ignoreErrors;
269267
const groupIndent = internalIndentationMap.get(this) || '';
270268

@@ -279,11 +277,6 @@ ObjectDefineProperties(Console.prototype, {
279277
}
280278
string = groupIndent + string;
281279
}
282-
283-
if (color) {
284-
string = styleText(color, string);
285-
}
286-
287280
string += '\n';
288281

289282
if (ignoreErrors === false) return stream.write(string);
@@ -382,15 +375,12 @@ const consoleMethods = {
382375
log(...args) {
383376
this[kWriteToConsole](kUseStdout, this[kFormatForStdout](args));
384377
},
378+
379+
385380
warn(...args) {
386-
const color = (shouldColorize(args) && 'yellow') || '';
387-
this[kWriteToConsole](kUseStderr, this[kFormatForStderr](args), color);
381+
this[kWriteToConsole](kUseStderr, this[kFormatForStderr](args));
388382
},
389383

390-
error(...args) {
391-
const color = (shouldColorize(args) && 'red') || '';
392-
this[kWriteToConsole](kUseStderr, this[kFormatForStderr](args), color);
393-
},
394384

395385
dir(object, options) {
396386
this[kWriteToConsole](kUseStdout, inspect(object, {
@@ -621,12 +611,6 @@ const iterKey = '(iteration index)';
621611

622612
const isArray = (v) => ArrayIsArray(v) || isTypedArray(v) || isBuffer(v);
623613

624-
// TODO: remove string type check once the styleText supports objects
625-
// Return true if all args are type string
626-
const shouldColorize = (args) => {
627-
return lazyUtilColors().hasColors && !ArrayPrototypeSome(args, (arg) => typeof arg !== 'string');
628-
};
629-
630614
function noop() {}
631615

632616
for (const method of ReflectOwnKeys(consoleMethods))
@@ -635,6 +619,7 @@ for (const method of ReflectOwnKeys(consoleMethods))
635619
Console.prototype.debug = Console.prototype.log;
636620
Console.prototype.info = Console.prototype.log;
637621
Console.prototype.dirxml = Console.prototype.log;
622+
Console.prototype.error = Console.prototype.warn;
638623
Console.prototype.groupCollapsed = Console.prototype.group;
639624

640625
function initializeGlobalConsole(globalConsole) {
Collapse file

‎test/parallel/test-repl.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-repl.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,6 @@ const errorTests = [
793793
'Object [console] {',
794794
' log: [Function: log],',
795795
' warn: [Function: warn],',
796-
' error: [Function: error],',
797796
' dir: [Function: dir],',
798797
' time: [Function: time],',
799798
' timeEnd: [Function: timeEnd],',
@@ -809,6 +808,7 @@ const errorTests = [
809808
/ {2}debug: \[Function: (debug|log)],/,
810809
/ {2}info: \[Function: (info|log)],/,
811810
/ {2}dirxml: \[Function: (dirxml|log)],/,
811+
/ {2}error: \[Function: (error|warn)],/,
812812
/ {2}groupCollapsed: \[Function: (groupCollapsed|group)],/,
813813
/ {2}Console: \[Function: Console],?/,
814814
...process.features.inspector ? [
Collapse file
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

2-
*(node:*) Warning: The 'NODE_DISABLE_COLORS' env is ignored due to the 'FORCE_COLOR' env being set.
3-
(Use `* --trace-warnings ...` to show where the warning was created)*
2+
(node:*) Warning: The 'NODE_DISABLE_COLORS' env is ignored due to the 'FORCE_COLOR' env being set.
3+
(Use `* --trace-warnings ...` to show where the warning was created)
Collapse file
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

2-
*(node:*) Warning: The 'NODE_DISABLE_COLORS' and 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
3-
(Use `* --trace-warnings ...` to show where the warning was created)*
2+
(node:*) Warning: The 'NODE_DISABLE_COLORS' and 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
3+
(Use `* --trace-warnings ...` to show where the warning was created)
Collapse file
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
*(node:*) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
2-
(Use `* --trace-warnings ...` to show where the warning was created)*
1+
(node:*) Warning: The 'NO_COLOR' env is ignored due to the 'FORCE_COLOR' env being set.
2+
(Use `* --trace-warnings ...` to show where the warning was created)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.