File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -48,17 +48,21 @@ module.exports = app => {
48
48
ignoreInitial : true
49
49
} ) . on ( 'all' , ( event , path ) => {
50
50
if ( event === 'change' || event === 'add' ) {
51
- // remove mock routes stack
52
- app . _router . stack . splice ( mockStartIndex , mockRoutesLength )
51
+ try {
52
+ // remove mock routes stack
53
+ app . _router . stack . splice ( mockStartIndex , mockRoutesLength )
53
54
54
- // clear routes cache
55
- unregisterRoutes ( )
55
+ // clear routes cache
56
+ unregisterRoutes ( )
56
57
57
- const mockRoutes = registerRoutes ( app )
58
- mockRoutesLength = mockRoutes . mockRoutesLength
59
- mockStartIndex = mockRoutes . mockStartIndex
58
+ const mockRoutes = registerRoutes ( app )
59
+ mockRoutesLength = mockRoutes . mockRoutesLength
60
+ mockStartIndex = mockRoutes . mockStartIndex
60
61
61
- console . log ( chalk . magentaBright ( `\n > Mock Server hot reload success! changed ${ path } ` ) )
62
+ console . log ( chalk . magentaBright ( `\n > Mock Server hot reload success! changed ${ path } ` ) )
63
+ } catch ( error ) {
64
+ console . log ( chalk . redBright ( error ) )
65
+ }
62
66
}
63
67
} )
64
68
}
You can’t perform that action at this time.
0 commit comments