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 => {
4848 ignoreInitial : true
4949 } ) . on ( 'all' , ( event , path ) => {
5050 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 )
5354
54- // clear routes cache
55- unregisterRoutes ( )
55+ // clear routes cache
56+ unregisterRoutes ( )
5657
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
6061
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+ }
6266 }
6367 } )
6468}
You can’t perform that action at this time.
0 commit comments