File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 22
33const os = require ( 'os' ) ;
44const { prompt } = require ( 'enquirer' ) ;
5+ const moment = require ( 'moment' ) ;
56
67var count = 0 ;
78
@@ -10,11 +11,11 @@ function emit(data) {
1011 data . forEach ( d => console . log ( d ) ) ;
1112}
1213
13- function pos ( label , color = '33' ) {
14+ function pos ( label , color = '33' , prefix = '' , suffix = '' ) {
1415 const stack = ( new Error ( ) ) . stack ;
1516 let tmp = stack . split ( '\n' ) ;
1617 let local = tmp [ 3 ] . indexOf ( 'at Object.jump' ) > - 1 ? tmp [ 4 ] : tmp [ 3 ] ;
17- process . stdout . write ( `\x1b[${ color } m${ label } ${ local . trim ( ) } \x1b[0m${ os . EOL } ` ) ;
18+ process . stdout . write ( `${ prefix } \x1b[${ color } m${ label } ${ local . trim ( ) } \x1b[0m${ suffix } ${ os . EOL } ` ) ;
1819}
1920
2021function dump ( ...data ) {
@@ -26,7 +27,7 @@ function dump(...data) {
2627}
2728
2829function log ( ...data ) {
29- pos ( 'log' , '38;5;243' ) ;
30+ pos ( 'log' , '38;5;243' , `\x1b[33m[ ${ moment ( ) . format ( 'YYYY-MM-DD HH:mm:ss' ) } ]\x1b[0m ` ) ;
3031 // eslint-disable-next-line no-console
3132 console . log . apply ( this , data ) ;
3233}
You can’t perform that action at this time.
0 commit comments