File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -149,9 +149,18 @@ exports.run = (options) => {
149
149
150
150
app . use ( serveIndex ( cwd ) ) ;
151
151
152
- http . createServer ( app ) . listen ( port , ( ) => {
152
+ const httpServer = http . createServer ( app )
153
+ httpServer . on ( 'error' , ( e ) => {
154
+ if ( e . code === 'EACCES' ) {
155
+ warn ( '权限不足, 请使用sudo执行' )
156
+ } else if ( e . code === 'EADDRINUSE' ) {
157
+ warn ( '端口 ' + port + ' 已经被占用, 请关闭占用该端口的程序或者使用其它端口.' )
158
+ }
159
+ process . exit ( 1 )
160
+ } )
161
+ httpServer . listen ( port , ( ) => {
153
162
warn ( 'Listening on port ' + port ) ;
154
- } ) ;
163
+ } )
155
164
156
165
// 权限降级
157
166
if ( process . env [ 'SUDO_UID' ] ) {
Original file line number Diff line number Diff line change @@ -114,6 +114,8 @@ exports.getCommands = () => {
114
114
let readRC = exports . readRC = ( ) => {
115
115
try {
116
116
return JSON5 . parse ( fs . readFileSync ( YKIT_RC , 'UTF-8' ) ) ;
117
+ } catch ( e ) {
118
+ // warn('读取 .ykitrc 失败!');
117
119
}
118
120
return { }
119
121
} ;
You can’t perform that action at this time.
0 commit comments