2
2
3
3
'use strict' ;
4
4
5
- var colors = require ( 'colors/safe ' ) ,
5
+ var chalk = require ( 'chalk ' ) ,
6
6
os = require ( 'os' ) ,
7
7
httpServer = require ( '../lib/http-server' ) ,
8
8
portfinder = require ( 'portfinder' ) ,
@@ -77,21 +77,21 @@ if (!argv.s && !argv.silent) {
77
77
if ( error ) {
78
78
logger . info (
79
79
'[%s] %s "%s %s" Error (%s): "%s"' ,
80
- date , ip , colors . red ( req . method ) , colors . red ( req . url ) ,
81
- colors . red ( error . status . toString ( ) ) , colors . red ( error . message )
80
+ date , ip , chalk . red ( req . method ) , chalk . red ( req . url ) ,
81
+ chalk . red ( error . status . toString ( ) ) , chalk . red ( error . message )
82
82
) ;
83
83
}
84
84
else {
85
85
logger . info (
86
86
'[%s] %s "%s %s" "%s"' ,
87
- date , ip , colors . cyan ( req . method ) , colors . cyan ( req . url ) ,
87
+ date , ip , chalk . cyan ( req . method ) , chalk . cyan ( req . url ) ,
88
88
req . headers [ 'user-agent' ]
89
89
) ;
90
90
}
91
91
}
92
92
} ;
93
93
}
94
- else if ( colors ) {
94
+ else if ( chalk ) {
95
95
logger = {
96
96
info : function ( ) { } ,
97
97
request : function ( ) { }
@@ -149,14 +149,14 @@ function listen(port) {
149
149
fs . lstatSync ( options . https . cert ) ;
150
150
}
151
151
catch ( err ) {
152
- logger . info ( colors . red ( 'Error: Could not find certificate ' + options . https . cert ) ) ;
152
+ logger . info ( chalk . red ( 'Error: Could not find certificate ' + options . https . cert ) ) ;
153
153
process . exit ( 1 ) ;
154
154
}
155
155
try {
156
156
fs . lstatSync ( options . https . key ) ;
157
157
}
158
158
catch ( err ) {
159
- logger . info ( colors . red ( 'Error: Could not find private key ' + options . https . key ) ) ;
159
+ logger . info ( chalk . red ( 'Error: Could not find private key ' + options . https . key ) ) ;
160
160
process . exit ( 1 ) ;
161
161
}
162
162
}
@@ -165,31 +165,31 @@ function listen(port) {
165
165
server . listen ( port , host , function ( ) {
166
166
var protocol = ssl ? 'https://' : 'http://' ;
167
167
168
- logger . info ( [ colors . yellow ( 'Starting up http-server, serving ' ) ,
169
- colors . cyan ( server . root ) ,
170
- ssl ? ( colors . yellow ( ' through' ) + colors . cyan ( ' https' ) ) : ''
168
+ logger . info ( [ chalk . yellow ( 'Starting up http-server, serving ' ) ,
169
+ chalk . cyan ( server . root ) ,
170
+ ssl ? ( chalk . yellow ( ' through' ) + chalk . cyan ( ' https' ) ) : ''
171
171
] . join ( '' ) ) ;
172
172
173
- logger . info ( [ colors . yellow ( '\nhttp-server settings: ' ) ,
174
- ( [ colors . yellow ( 'CORS: ' ) , argv . cors ? colors . cyan ( argv . cors ) : colors . red ( 'disabled' ) ] . join ( '' ) ) ,
175
- ( [ colors . yellow ( 'Cache: ' ) , argv . c ? ( argv . c === '-1' ? colors . red ( 'disabled' ) : colors . cyan ( argv . c + ' seconds' ) ) : colors . cyan ( '3600 seconds' ) ] . join ( '' ) ) ,
176
- ( [ colors . yellow ( 'Connection Timeout: ' ) , argv . t === '0' ? colors . red ( 'disabled' ) : ( argv . t ? colors . cyan ( argv . t + ' seconds' ) : colors . cyan ( '120 seconds' ) ) ] . join ( '' ) ) ,
177
- ( [ colors . yellow ( 'Directory Listings: ' ) , argv . d ? colors . red ( 'not visible' ) : colors . cyan ( 'visible' ) ] . join ( '' ) ) ,
178
- ( [ colors . yellow ( 'AutoIndex: ' ) , argv . i ? colors . red ( 'not visible' ) : colors . cyan ( 'visible' ) ] . join ( '' ) ) ,
179
- ( [ colors . yellow ( 'Serve GZIP Files: ' ) , argv . g || argv . gzip ? colors . cyan ( 'true' ) : colors . red ( 'false' ) ] . join ( '' ) ) ,
180
- ( [ colors . yellow ( 'Serve Brotli Files: ' ) , argv . b || argv . brotli ? colors . cyan ( 'true' ) : colors . red ( 'false' ) ] . join ( '' ) ) ,
181
- ( [ colors . yellow ( 'Default File Extension: ' ) , argv . e ? colors . cyan ( argv . e ) : ( argv . ext ? colors . cyan ( argv . ext ) : colors . red ( 'none' ) ) ] . join ( '' ) )
173
+ logger . info ( [ chalk . yellow ( '\nhttp-server settings: ' ) ,
174
+ ( [ chalk . yellow ( 'CORS: ' ) , argv . cors ? chalk . cyan ( argv . cors ) : chalk . red ( 'disabled' ) ] . join ( '' ) ) ,
175
+ ( [ chalk . yellow ( 'Cache: ' ) , argv . c ? ( argv . c === '-1' ? chalk . red ( 'disabled' ) : chalk . cyan ( argv . c + ' seconds' ) ) : chalk . cyan ( '3600 seconds' ) ] . join ( '' ) ) ,
176
+ ( [ chalk . yellow ( 'Connection Timeout: ' ) , argv . t === '0' ? chalk . red ( 'disabled' ) : ( argv . t ? chalk . cyan ( argv . t + ' seconds' ) : chalk . cyan ( '120 seconds' ) ) ] . join ( '' ) ) ,
177
+ ( [ chalk . yellow ( 'Directory Listings: ' ) , argv . d ? chalk . red ( 'not visible' ) : chalk . cyan ( 'visible' ) ] . join ( '' ) ) ,
178
+ ( [ chalk . yellow ( 'AutoIndex: ' ) , argv . i ? chalk . red ( 'not visible' ) : chalk . cyan ( 'visible' ) ] . join ( '' ) ) ,
179
+ ( [ chalk . yellow ( 'Serve GZIP Files: ' ) , argv . g || argv . gzip ? chalk . cyan ( 'true' ) : chalk . red ( 'false' ) ] . join ( '' ) ) ,
180
+ ( [ chalk . yellow ( 'Serve Brotli Files: ' ) , argv . b || argv . brotli ? chalk . cyan ( 'true' ) : chalk . red ( 'false' ) ] . join ( '' ) ) ,
181
+ ( [ chalk . yellow ( 'Default File Extension: ' ) , argv . e ? chalk . cyan ( argv . e ) : ( argv . ext ? chalk . cyan ( argv . ext ) : chalk . red ( 'none' ) ) ] . join ( '' ) )
182
182
] . join ( '\n' ) ) ;
183
183
184
- logger . info ( colors . yellow ( '\nAvailable on:' ) ) ;
184
+ logger . info ( chalk . yellow ( '\nAvailable on:' ) ) ;
185
185
186
186
if ( argv . a && host !== '0.0.0.0' ) {
187
- logger . info ( ` ${ protocol } ${ host } :${ colors . green ( port . toString ( ) ) } ` ) ;
187
+ logger . info ( ` ${ protocol } ${ host } :${ chalk . green ( port . toString ( ) ) } ` ) ;
188
188
} else {
189
189
Object . keys ( ifaces ) . forEach ( function ( dev ) {
190
190
ifaces [ dev ] . forEach ( function ( details ) {
191
191
if ( details . family === 'IPv4' ) {
192
- logger . info ( ( ' ' + protocol + details . address + ':' + colors . green ( port . toString ( ) ) ) ) ;
192
+ logger . info ( ( ' ' + protocol + details . address + ':' + chalk . green ( port . toString ( ) ) ) ) ;
193
193
}
194
194
} ) ;
195
195
} ) ;
@@ -225,11 +225,11 @@ if (process.platform === 'win32') {
225
225
}
226
226
227
227
process . on ( 'SIGINT' , function ( ) {
228
- logger . info ( colors . red ( 'http-server stopped.' ) ) ;
228
+ logger . info ( chalk . red ( 'http-server stopped.' ) ) ;
229
229
process . exit ( ) ;
230
230
} ) ;
231
231
232
232
process . on ( 'SIGTERM' , function ( ) {
233
- logger . info ( colors . red ( 'http-server stopped.' ) ) ;
233
+ logger . info ( chalk . red ( 'http-server stopped.' ) ) ;
234
234
process . exit ( ) ;
235
235
} ) ;
0 commit comments