Skip to content

Commit 4b36016

Browse files
committed
Fix server watch restart\n\nstart() is now called in destroy callback. Has watch callback is beeing called twice (on windows at least) reset server variable in start()
1 parent 54a8dcf commit 4b36016

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

bin/index.js

100755100644
File mode changed.

src/cli/run.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ module.exports = function(argv) {
102102

103103
console.log(chalk.gray(' Loading', source))
104104

105+
server = undefined
106+
105107
// create db and load object, JSON file, JS or HTTP database
106108
return load(source).then(db => {
107109
// Load additional routes
@@ -204,8 +206,7 @@ module.exports = function(argv) {
204206
console.log(
205207
chalk.gray(` ${source} has changed, reloading...`)
206208
)
207-
server && server.destroy()
208-
start()
209+
server && server.destroy(() => start())
209210
}
210211
}
211212
}
@@ -222,8 +223,7 @@ module.exports = function(argv) {
222223
console.log(
223224
chalk.gray(` ${argv.routes} has changed, reloading...`)
224225
)
225-
server && server.destroy()
226-
start()
226+
server && server.destroy(() => start())
227227
}
228228
}
229229
})

0 commit comments

Comments
 (0)