Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wait for status codes #288

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 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 Expand Up @@ -253,4 +252,4 @@ function spawnChecker(
})
}

export default checker
export default checker
Loading