Skip to content

Commit

Permalink
chore: update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishqmanuja committed Jan 15, 2024
1 parent 3958e15 commit 327468e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import { BuildOptions, build } from "esbuild";
import { execa } from "execa";
import { copyFile } from "fs/promises";
import pkg from "package.json";

const VERSION = pkg.version ?? "0.0.0";
const [VERSION_MAJOR = "", VERSION_MINOR = "", VERSION_PATCH = ""] =
VERSION.split(".");

const BUNDLE_PATH = "./out/vryjs.mjs";
const COPY_BUNDLE_PATH = "./bin/vryjs.mjs";
const EXECUTABLE_PATH = "./out/vryjs.exe";

const isProduction =
process.env.NODE_ENV === "production" ||
process.argv.slice(2).includes("--prod");

const makeBinary = process.argv.slice(2).includes("--bin");
const copyBundle = process.argv.slice(2).includes("--copy");

const ESM_FIX_BANNER = `
// ESM Fixes
Expand Down Expand Up @@ -120,6 +123,13 @@ try {
"🥳 Build success",
`[ ${(performance.now() - start).toFixed(2)}ms ]`,
);

if (copyBundle) {
await copyFile(BUNDLE_PATH, COPY_BUNDLE_PATH);
process.stdout.write("\n");
console.log(`📦 Copied ${BUNDLE_PATH} to ${COPY_BUNDLE_PATH}`);
}

process.exit(0);
} catch (e) {
process.stdout.write("\n");
Expand Down

0 comments on commit 327468e

Please sign in to comment.