Skip to content

Commit

Permalink
wait for error codes
Browse files Browse the repository at this point in the history
  • Loading branch information
philipgriffin committed Dec 11, 2023
1 parent d4d8c8e commit 5edb917
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/vite-plugin-checker/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,16 @@ export function checker(userConfig: UserPluginConfig): Plugin {
execPath: process.execPath,
})

// spawn an async runner that we don't wait for in order to avoid blocking the build from continuing in parallel
;(async () => {
const exitCodes = await Promise.all(
checkers.map((checker) => spawnChecker(checker, userConfig, localEnv))
)
const exitCode = exitCodes.find((code) => code !== 0) ?? 0
// do not exit the process if run `vite build --watch`
if (exitCode !== 0 && !buildWatch) {
process.exit(exitCode)
}
})()
const spawnedCheckers = checkers.map((checker2) => spawnChecker(checker2, userConfig, localEnv));

// wait for checker states while avoiding blocking the build from continuing in parallel
Promise.all(spawnedCheckers)
.then((exitCodes) => {
const exitCode = exitCodes.find((code) => code !== 0) ?? 0;
if (exitCode !== 0 && !buildWatch) {
process.exit(exitCode);
}
});
},
configureServer(server) {
if (initialized) return
Expand Down

0 comments on commit 5edb917

Please sign in to comment.