GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — console: use validateOneOf for colorMode validation · nodejs/node@a110409

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/console
    • constructor.js
  • test/parallel
    • test-console-tty-colors.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/console/constructor.js‎

Copy file name to clipboardExpand all lines: lib/internal/console/constructor.js
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,14 @@ const {
4444
isStackOverflowError,
4545
codes: {
4646
ERR_CONSOLE_WRITABLE_STREAM,
47-
ERR_INVALID_ARG_VALUE,
4847
ERR_INCOMPATIBLE_OPTION_PAIR,
4948
},
5049
} = require('internal/errors');
5150
const {
5251
validateArray,
5352
validateInteger,
5453
validateObject,
54+
validateOneOf,
5555
} = require('internal/validators');
5656
const { previewEntries } = internalBinding('util');
5757
const { Buffer: { isBuffer } } = require('buffer');
@@ -135,8 +135,7 @@ function Console(options /* or: stdout, stderr, ignoreErrors = true */) {
135135
throw new ERR_CONSOLE_WRITABLE_STREAM('stderr');
136136
}
137137

138-
if (typeof colorMode !== 'boolean' && colorMode !== 'auto')
139-
throw new ERR_INVALID_ARG_VALUE('colorMode', colorMode);
138+
validateOneOf(colorMode, 'colorMode', ['auto', true, false]);
140139

141140
if (groupIndentation !== undefined) {
142141
validateInteger(groupIndentation, 'groupIndentation',
Collapse file

‎test/parallel/test-console-tty-colors.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-console-tty-colors.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ check(false, false, false);
6767
});
6868
},
6969
{
70-
message: `The argument 'colorMode' is invalid. Received ${received}`,
70+
message: `The argument 'colorMode' must be one of: 'auto', true, false. Received ${received}`,
7171
code: 'ERR_INVALID_ARG_VALUE'
7272
}
7373
);

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.