Skip to content

Commit 0d57698

Browse files
committed
feat: bake git commit and build date into --version string, bump to 0.3.0-beta
1 parent 437cdd9 commit 0d57698

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "chadscript",
3-
"version": "0.2.0-beta",
3+
"version": "0.3.0-beta",
44
"description": "A JavaScript to native code compiler using LLVM",
55
"type": "module",
66
"main": "dist/chad-node.js",

scripts/gen-version.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
import { readFileSync, writeFileSync } from "fs";
2+
import { execSync } from "child_process";
3+
24
const pkg = JSON.parse(readFileSync("package.json", "utf8"));
3-
writeFileSync("src/version.ts", `export const VERSION = "${pkg.version}";\n`);
5+
6+
let gitCommit = "unknown";
7+
try {
8+
gitCommit = execSync("git rev-parse --short HEAD", { stdio: ["ignore", "pipe", "ignore"] })
9+
.toString()
10+
.trim();
11+
} catch {
12+
// not a git checkout (e.g., building from a release tarball)
13+
}
14+
15+
const buildDate = new Date().toISOString().slice(0, 10);
16+
const fullVersion = `${pkg.version}-${gitCommit}-${buildDate}`;
17+
18+
writeFileSync("src/version.ts", `export const VERSION = "${fullVersion}";\n`);

0 commit comments

Comments
 (0)