File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11'use strict' ;
2+ // @flow
23const supportsColor = require ( './supports-color' ) ;
34
45// Find more colors/styles in
56// https://github.com/chalk/ansi-styles/blob/main/index.js
6- const colors = {
7- blue : { open : '\x1B[34m' , close : '\x1B[39m' } ,
8- red : { open : '\x1B[31m' , close : '\x1B[39m' } ,
9- } ;
10-
11- const chalk = { supportsColor } ;
127
13- for ( const [ styleName , style ] of Object . entries ( colors ) ) {
14- chalk [ styleName ] = ( string ) => {
15- if ( ! supportsColor || ! string ) {
16- return string ;
17- }
8+ function red ( string /*: string */ ) /*: string */ {
9+ return supportsColor ? `\x1B[31m${ string } \x1B[39m` : string ;
10+ }
1811
19- return style . open + string + style . close ;
20- } ;
12+ function blue ( string /*: string */ ) /*: string */ {
13+ return supportsColor ? `\x1B[34m ${ string } \x1B[39m` : string ;
2114}
2215
23- module . exports = chalk ;
16+ module . exports = {
17+ supportsColor,
18+
19+ red,
20+ blue,
21+ } ;
You can’t perform that action at this time.
0 commit comments