GeezerVison is showing github.com — console: use validateOneOf for colorMode validation · nodejs/node@a110409
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/console/constructor.js +2-3Lines changed: 2 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,14 +44,14 @@ const { | 44 | 44 | isStackOverflowError, | 45 | 45 | codes: { | 46 | 46 | ERR_CONSOLE_WRITABLE_STREAM, | 47 | | - ERR_INVALID_ARG_VALUE, | 48 | 47 | ERR_INCOMPATIBLE_OPTION_PAIR, | 49 | 48 | }, | 50 | 49 | } = require('internal/errors'); | 51 | 50 | const { | 52 | 51 | validateArray, | 53 | 52 | validateInteger, | 54 | 53 | validateObject, | | 54 | + validateOneOf, | 55 | 55 | } = require('internal/validators'); | 56 | 56 | const { previewEntries } = internalBinding('util'); | 57 | 57 | const { Buffer: { isBuffer } } = require('buffer'); | @@ -135,8 +135,7 @@ function Console(options /* or: stdout, stderr, ignoreErrors = true */) { | 135 | 135 | throw new ERR_CONSOLE_WRITABLE_STREAM('stderr'); | 136 | 136 | } | 137 | 137 |
| 138 | | - if (typeof colorMode !== 'boolean' && colorMode !== 'auto') | 139 | | - throw new ERR_INVALID_ARG_VALUE('colorMode', colorMode); | | 138 | + validateOneOf(colorMode, 'colorMode', ['auto', true, false]); | 140 | 139 |
| 141 | 140 | if (groupIndentation !== undefined) { | 142 | 141 | validateInteger(groupIndentation, 'groupIndentation', | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-console-tty-colors.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -67,7 +67,7 @@ check(false, false, false); | 67 | 67 | }); | 68 | 68 | }, | 69 | 69 | { | 70 | | - message: `The argument 'colorMode' is invalid. Received ${received}`, | | 70 | + message: `The argument 'colorMode' must be one of: 'auto', true, false. Received ${received}`, | 71 | 71 | code: 'ERR_INVALID_ARG_VALUE' | 72 | 72 | } | 73 | 73 | ); | |
|