Skip to content

Commit cfacd95

Browse files
committed
fix: unlink .dev file on exit
1 parent 13af2a6 commit cfacd95

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

packages/vite-plugin-kirby/src/index.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ ${Object.entries(config)
3838
.join(',\n')}
3939
];`
4040

41+
let exitHandlersBound = false
42+
4143
export default (
4244
{
4345
watch = true,
@@ -90,6 +92,19 @@ export default (
9092
writeFile(devPath, `VITE_SERVER=${config.server.origin}`)
9193
})
9294

95+
if (!exitHandlersBound) {
96+
const clean = () => {
97+
unlink(devPath).catch((_e: Error) => {})
98+
}
99+
100+
process.on('exit', clean)
101+
process.on('SIGINT', process.exit)
102+
process.on('SIGTERM', process.exit)
103+
process.on('SIGHUP', process.exit)
104+
105+
exitHandlersBound = true
106+
}
107+
93108
if (watch) {
94109
const defaultPaths = [
95110
'../site/(templates|snippets|controllers|models|layouts)/**/*.php',
@@ -101,8 +116,6 @@ export default (
101116
}
102117
},
103118

104-
buildStart() {
105-
unlink(devPath).catch((_e: Error) => {})
106-
},
119+
buildStart() {},
107120
}
108121
}

0 commit comments

Comments
 (0)