Skip to content

Commit

Permalink
Grathfully exit if vite.config.ts not present
Browse files Browse the repository at this point in the history
  • Loading branch information
garronej committed Dec 7, 2024
1 parent 59f6457 commit 4291fbb
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions src/bin/updateTypes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
import * as child_process from "child_process";
import { updateTypingScriptEnvName } from "../constants";

export function updateTypes() {
child_process.execSync("npx vite", {
"env": {
export async function updateTypes(): Promise<void> {
const child = child_process.spawn("npx", ["vite", "dev"], {
env: {
...process.env,
[updateTypingScriptEnvName]: ""
},
shell: true
});

child.stdout.on("data", data => {
const dataStr = data.toString("utf8");

if (dataStr.includes("VITE") && dataStr.includes("ready in")) {
console.log(
"vite-envs vite plugin not enabled, skipping update-types (Ok in Docker build stage)"
);
process.exit(0);
}

process.stdout.write(data);
});

child.stderr.on("data", data => process.stderr.write(data));

await new Promise<void>(resolve => {
child.on("exit", code => {
if (code !== 0) {
process.exit(code ?? -1);
}
resolve();
});
});

console.log(`src/vite-env.d.ts has been updated`);
}

0 comments on commit 4291fbb

Please sign in to comment.