Skip to content

Commit

Permalink
fix(module): close nuxt before shutting down
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Dec 18, 2023
1 parent ae37b0e commit 17cf943
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ export default defineNuxtModule<NuxtVitestOptions>({
// Start Vitest
const promise = startVitest('test', [], defu(overrides, viteConfig.test), viteConfig)
promise.catch(() => process.exit(1))

if (watchMode) {
logger.info(`Vitest UI starting on ${URL}`)
nuxt.hook('close', () => promise.then(v => v?.close()))
await new Promise(resolve => setTimeout(resolve, 1000))
} else {
promise.then(v => v?.close()).then(() => process.exit())
promise.catch(() => process.exit(1))
promise.then((v) => nuxt.close().then(() => v?.close()).then(() => process.exit()))
}

loaded = true
Expand Down

0 comments on commit 17cf943

Please sign in to comment.