File tree Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Expand file tree Collapse file tree 2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -389,9 +389,18 @@ exports.run = function (options) {
389
389
390
390
servers . push ( extend ( http . createServer ( app ) , { _port : port } ) ) ;
391
391
if ( isHttps ) {
392
+ var globalConfig = JSON . parse ( fs . readFileSync ( YKIT_RC , { encoding : 'utf8' } ) ) ;
393
+
394
+ if ( ! globalConfig [ 'https-key' ] || ! globalConfig [ 'https-crt' ] ) {
395
+ warn ( '缺少 https 证书/秘钥配置,请使用以下命令设置:' ) ;
396
+ ! globalConfig [ 'https-key' ] && warn ( 'ykit config set https-key <path-to-your-key>' ) ;
397
+ ! globalConfig [ 'https-crt' ] && warn ( 'ykit config set https-crt <path-to-your-crt>' ) ;
398
+ process . exit ( 1 ) ;
399
+ }
400
+
392
401
var httpsOpts = {
393
- key : fs . readFileSync ( sysPath . join ( __dirname , '../config/ https/server. key') ) ,
394
- cert : fs . readFileSync ( sysPath . join ( __dirname , '../config/ https/server. crt') )
402
+ key : fs . readFileSync ( globalConfig [ ' https- key'] ) ,
403
+ cert : fs . readFileSync ( globalConfig [ ' https- crt'] )
395
404
} ;
396
405
servers . push ( extend ( https . createServer ( httpsOpts , app ) , { _port : '443' , _isHttps : true } ) ) ;
397
406
}
Original file line number Diff line number Diff line change @@ -371,9 +371,18 @@ exports.run = (options) => {
371
371
372
372
servers . push ( extend ( http . createServer ( app ) , { _port : port } ) ) ;
373
373
if ( isHttps ) {
374
+ const globalConfig = JSON . parse ( fs . readFileSync ( YKIT_RC , { encoding : 'utf8' } ) ) ;
375
+
376
+ if ( ! globalConfig [ 'https-key' ] || ! globalConfig [ 'https-crt' ] ) {
377
+ warn ( '缺少 https 证书/秘钥配置,请使用以下命令设置:' ) ;
378
+ ! globalConfig [ 'https-key' ] && warn ( 'ykit config set https-key <path-to-your-key>' ) ;
379
+ ! globalConfig [ 'https-crt' ] && warn ( 'ykit config set https-crt <path-to-your-crt>' ) ;
380
+ process . exit ( 1 ) ;
381
+ }
382
+
374
383
const httpsOpts = {
375
- key : fs . readFileSync ( sysPath . join ( __dirname , '../config/ https/server. key') ) ,
376
- cert : fs . readFileSync ( sysPath . join ( __dirname , '../config/ https/server. crt') )
384
+ key : fs . readFileSync ( globalConfig [ ' https- key'] ) ,
385
+ cert : fs . readFileSync ( globalConfig [ ' https- crt'] )
377
386
} ;
378
387
servers . push ( extend ( https . createServer ( httpsOpts , app ) , { _port : '443' , _isHttps : true } ) ) ;
379
388
}
You can’t perform that action at this time.
0 commit comments