File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -183,6 +183,7 @@ app.listen(port, () => {
183183// Watch file for changes
184184if ( process . env [ "NODE_ENV" ] !== "production" ) {
185185 let writing = false ; // true if the file is being written to by the app
186+ let hadReadError = false ;
186187 let prevEndpoints = "" ;
187188
188189 observer . onWriteStart = ( ) => {
@@ -200,16 +201,18 @@ if (process.env["NODE_ENV"] !== "production") {
200201 }
201202
202203 const nextEndpoints = JSON . stringify ( Object . keys ( data ) . sort ( ) ) ;
203- if ( prevEndpoints !== nextEndpoints ) {
204+ if ( hadReadError || prevEndpoints !== nextEndpoints ) {
204205 console . log ( ) ;
205206 logRoutes ( data ) ;
206207 }
208+ hadReadError = false ;
207209 } ;
208210 watch ( file ) . on ( "change" , ( ) => {
209211 // Do no reload if the file is being written to by the app
210212 if ( ! writing ) {
211213 db . read ( ) . catch ( ( e ) => {
212214 if ( e instanceof SyntaxError ) {
215+ hadReadError = true ;
213216 return console . log ( chalk . red ( [ "" , `Error parsing ${ file } ` , e . message ] . join ( "\n" ) ) ) ;
214217 }
215218 console . log ( e ) ;
You can’t perform that action at this time.
0 commit comments