Skip to content

Commit

Permalink
ensure custom 404 page shows after server restarts (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
timacdonald authored Sep 15, 2022
1 parent ee891f7 commit 64bef2b
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,20 @@ function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlug
}
})

if (exitHandlersBound) {
return
}

const clean = () => {
if (fs.existsSync(pluginConfig.hotFile)) {
fs.rmSync(pluginConfig.hotFile)
if (! exitHandlersBound) {
const clean = () => {
if (fs.existsSync(pluginConfig.hotFile)) {
fs.rmSync(pluginConfig.hotFile)
}
}
}

process.on('exit', clean)
process.on('SIGINT', process.exit)
process.on('SIGTERM', process.exit)
process.on('SIGHUP', process.exit)
process.on('exit', clean)
process.on('SIGINT', process.exit)
process.on('SIGTERM', process.exit)
process.on('SIGHUP', process.exit)

exitHandlersBound = true
exitHandlersBound = true
}

return () => server.middlewares.use((req, res, next) => {
if (req.url === '/index.html') {
Expand Down

0 comments on commit 64bef2b

Please sign in to comment.