1
- import { deburr , isPlainObject , trim , upperFirst } from 'lodash'
1
+ import { deburr , isPlainObject , trim , upperFirst } from 'lodash-es '
2
2
import { basename , dirname , extname , normalize , sep , posix } from 'path'
3
- import { JSONSchema , LinkedJSONSchema , Parent } from './types/JSONSchema'
3
+ import { JSONSchema , LinkedJSONSchema , Parent } from './types/JSONSchema.js '
4
4
import { JSONSchema4 } from 'json-schema'
5
5
import yaml from 'js-yaml'
6
6
@@ -208,7 +208,7 @@ export function error(...messages: any[]): void {
208
208
if ( ! process . env . VERBOSE ) {
209
209
return console . error ( messages )
210
210
}
211
- console . error ( getStyledTextForLogging ( 'red' ) ?.( 'error' ) , ...messages )
211
+ getStyledTextForLogging ( 'red' ) . then ( text => console . error ( text ?.( 'error' ) , ...messages ) )
212
212
}
213
213
214
214
type LogStyle = 'blue' | 'cyan' | 'green' | 'magenta' | 'red' | 'white' | 'yellow'
@@ -221,31 +221,35 @@ export function log(style: LogStyle, title: string, ...messages: unknown[]): voi
221
221
if ( messages . length > 1 && typeof messages [ messages . length - 1 ] !== 'string' ) {
222
222
lastMessage = messages . splice ( messages . length - 1 , 1 )
223
223
}
224
- console . info ( require ( 'cli-color' ) . whiteBright . bgCyan ( 'debug' ) , getStyledTextForLogging ( style ) ?.( title ) , ...messages )
225
- if ( lastMessage ) {
226
- console . dir ( lastMessage , { depth : 6 , maxArrayLength : 6 } )
227
- }
224
+ import ( 'cli-color' ) . then ( color => {
225
+ getStyledTextForLogging ( style ) . then ( text => {
226
+ console . info ( color . whiteBright . bgCyan ( 'debug' ) , text ?.( title ) , ...messages )
227
+ if ( lastMessage ) {
228
+ console . dir ( lastMessage , { depth : 6 , maxArrayLength : 6 } )
229
+ }
230
+ } )
231
+ } )
228
232
}
229
233
230
- function getStyledTextForLogging ( style : LogStyle ) : ( ( text : string ) => string ) | undefined {
234
+ function getStyledTextForLogging ( style : LogStyle ) : Promise < ( ( text : string ) => string ) | undefined > {
231
235
if ( ! process . env . VERBOSE ) {
232
- return
236
+ return Promise . resolve ( undefined )
233
237
}
234
238
switch ( style ) {
235
239
case 'blue' :
236
- return require ( 'cli-color' ) . whiteBright . bgBlue
240
+ return import ( 'cli-color' ) . then ( color => color . whiteBright . bgBlue )
237
241
case 'cyan' :
238
- return require ( 'cli-color' ) . whiteBright . bgCyan
242
+ return import ( 'cli-color' ) . then ( color => color . whiteBright . bgCyan )
239
243
case 'green' :
240
- return require ( 'cli-color' ) . whiteBright . bgGreen
244
+ return import ( 'cli-color' ) . then ( color => color . whiteBright . bgGreen )
241
245
case 'magenta' :
242
- return require ( 'cli-color' ) . whiteBright . bgMagenta
246
+ return import ( 'cli-color' ) . then ( color => color . whiteBright . bgMagenta )
243
247
case 'red' :
244
- return require ( 'cli-color' ) . whiteBright . bgRedBright
248
+ return import ( 'cli-color' ) . then ( color => color . whiteBright . bgRedBright )
245
249
case 'white' :
246
- return require ( 'cli-color' ) . black . bgWhite
250
+ return import ( 'cli-color' ) . then ( color => color . black . bgWhite )
247
251
case 'yellow' :
248
- return require ( 'cli-color' ) . whiteBright . bgYellow
252
+ return import ( 'cli-color' ) . then ( color => color . whiteBright . bgYellow )
249
253
}
250
254
}
251
255
0 commit comments