File tree Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Expand file tree Collapse file tree 4 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,12 @@ console.log(
8080console . log (
8181 util . styleText ( [ "red" , "green" ] , "text" ) ,
8282) ;
83+ console . log (
84+ util . styleText ( "blue" , "text" , { validateStream : false } ) ,
85+ ) ;
86+ console . log (
87+ util . styleText ( "yellow" , "text" , { stream : process . stdout } ) ,
88+ ) ;
8389
8490// util.callbackify
8591class callbackifyTest {
Original file line number Diff line number Diff line change @@ -1466,6 +1466,18 @@ declare module "util" {
14661466 | "reset"
14671467 | "strikethrough"
14681468 | "underline" ;
1469+ export interface StyleTextOptions {
1470+ /**
1471+ * When true, `stream` is checked to see if it can handle colors.
1472+ * @default true
1473+ */
1474+ validateStream ?: boolean | undefined ;
1475+ /**
1476+ * A stream that will be validated if it can be colored.
1477+ * @default process.stdout
1478+ */
1479+ stream ?: NodeJS . WritableStream | undefined ;
1480+ }
14691481 /**
14701482 * This function returns a formatted text considering the `format` passed
14711483 * for printing in a terminal. It is aware of the terminal's capabilities
@@ -1518,6 +1530,7 @@ declare module "util" {
15181530 | Modifiers
15191531 | Array < ForegroundColors | BackgroundColors | Modifiers > ,
15201532 text : string ,
1533+ options ?: StyleTextOptions ,
15211534 ) : string ;
15221535 /**
15231536 * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextDecoder` API.
Original file line number Diff line number Diff line change @@ -71,6 +71,12 @@ console.log(
7171console . log (
7272 util . styleText ( [ "red" , "green" ] , "text" ) ,
7373) ;
74+ console . log (
75+ util . styleText ( "blue" , "text" , { validateStream : false } ) ,
76+ ) ;
77+ console . log (
78+ util . styleText ( "yellow" , "text" , { stream : process . stdout } ) ,
79+ ) ;
7480
7581// util.callbackify
7682class callbackifyTest {
Original file line number Diff line number Diff line change @@ -1241,6 +1241,18 @@ declare module "util" {
12411241 | "reset"
12421242 | "strikethrough"
12431243 | "underline" ;
1244+ export interface StyleTextOptions {
1245+ /**
1246+ * When true, `stream` is checked to see if it can handle colors.
1247+ * @default true
1248+ */
1249+ validateStream ?: boolean | undefined ;
1250+ /**
1251+ * A stream that will be validated if it can be colored.
1252+ * @default process.stdout
1253+ */
1254+ stream ?: NodeJS . WritableStream | undefined ;
1255+ }
12441256 /**
12451257 * Stability: 1.1 - Active development
12461258 *
@@ -1281,6 +1293,7 @@ declare module "util" {
12811293 | Modifiers
12821294 | Array < ForegroundColors | BackgroundColors | Modifiers > ,
12831295 text : string ,
1296+ options ?: StyleTextOptions ,
12841297 ) : string ;
12851298 /**
12861299 * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextDecoder` API.
You can’t perform that action at this time.
0 commit comments