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

Fix early exit when enableBuild is true #61

Merged
merged 5 commits into from
Jul 31, 2021
Merged
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
20 changes: 10 additions & 10 deletions packages/vite-plugin-checker/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,23 @@ export default function Plugin(userConfig: UserPluginConfig): Plugin {
buildStart: () => {
// for build mode
// run a bin command in a separated process
if (viteMode !== 'build') return
if (viteMode !== 'build') return;

// do not do anything when disable build mode
if (!enableBuild) return
if (!enableBuild) return;

const localEnv = npmRunPath.env({
env: process.env,
cwd: process.cwd(),
execPath: process.execPath,
})

Promise.all(checkers.map((checker) => spawnChecker(checker, userConfig, localEnv))).then(
(exitCodes) => {
const exitCode = exitCodes.find((code) => code !== 0) || 0
process.exit(exitCode)
}
)
});

// 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;
if (exitCode !== 0) process.exit(exitCode);
})();
},
configureServer(server) {
// for dev mode (2/2)
Expand Down