@@ -3,7 +3,7 @@ import {basename, dirname, extname, normalize, sep, posix} from 'path'
3
3
import { Intersection , JSONSchema , LinkedJSONSchema , NormalizedJSONSchema , Parent } from './types/JSONSchema'
4
4
import { JSONSchema4 } from 'json-schema'
5
5
import yaml from 'js-yaml'
6
- import type { Format } from 'cli-color '
6
+ import pc from 'picocolors '
7
7
8
8
// TODO: pull out into a separate package
9
9
export function Try < T > ( fn : ( ) => T , err : ( e : Error ) => any ) : T {
@@ -243,7 +243,7 @@ export function log(style: LogStyle, title: string, ...messages: unknown[]): voi
243
243
if ( messages . length > 1 && typeof messages [ messages . length - 1 ] !== 'string' ) {
244
244
lastMessage = messages . splice ( messages . length - 1 , 1 )
245
245
}
246
- console . info ( color ( ) ? .whiteBright . bgCyan ( 'debug' ) , getStyledTextForLogging ( style ) ?.( title ) , ...messages )
246
+ console . info ( pc . bgCyan ( pc . whiteBright ( 'debug' ) ) , getStyledTextForLogging ( style ) ?.( title ) , ...messages )
247
247
if ( lastMessage ) {
248
248
console . dir ( lastMessage , { depth : 6 , maxArrayLength : 6 } )
249
249
}
@@ -255,19 +255,19 @@ function getStyledTextForLogging(style: LogStyle): ((text: string) => string) |
255
255
}
256
256
switch ( style ) {
257
257
case 'blue' :
258
- return color ( ) ?. whiteBright . bgBlue
258
+ return ( text ) => pc . bgBlue ( pc . whiteBright ( text ) )
259
259
case 'cyan' :
260
- return color ( ) ?. whiteBright . bgCyan
260
+ return ( text ) => pc . bgCyan ( pc . whiteBright ( text ) )
261
261
case 'green' :
262
- return color ( ) ?. whiteBright . bgGreen
262
+ return ( text ) => pc . bgGreen ( pc . whiteBright ( text ) )
263
263
case 'magenta' :
264
- return color ( ) ?. whiteBright . bgMagenta
264
+ return ( text ) => pc . bgMagenta ( pc . whiteBright ( text ) )
265
265
case 'red' :
266
- return color ( ) ?. whiteBright . bgRedBright
266
+ return ( text ) => pc . bgRedBright ( pc . whiteBright ( text ) )
267
267
case 'white' :
268
- return color ( ) ?. black . bgWhite
268
+ return ( text ) => pc . bgWhite ( pc . black ( text ) )
269
269
case 'yellow' :
270
- return color ( ) ?. whiteBright . bgYellow
270
+ return ( text ) => pc . bgYellow ( pc . whiteBright ( text ) )
271
271
}
272
272
}
273
273
@@ -412,11 +412,3 @@ export function parseFileAsJSONSchema(filename: string | null, contents: string)
412
412
function isYaml ( filename : string ) {
413
413
return filename . endsWith ( '.yaml' ) || filename . endsWith ( '.yml' )
414
414
}
415
-
416
- function color ( ) : Format {
417
- let cliColor
418
- try {
419
- cliColor = require ( 'cli-color' )
420
- } catch { }
421
- return cliColor
422
- }
0 commit comments