Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"build:cli": "tsc -p tsconfig.src.json",
"typecheck:cli": "tsc -p tsconfig.cli.json",
"prepare": "if command -v tsc >/dev/null 2>&1 || [ -x node_modules/.bin/tsc ]; then npm run build:cli; fi && npm install --omit=dev --ignore-scripts 2>/dev/null || true && if [ -d .git ]; then if command -v prek >/dev/null 2>&1; then prek install; elif [ -d node_modules/@j178/prek ]; then echo \"ERROR: prek package found but binary not in PATH\" && exit 1; else echo \"Skipping git hook setup (prek not installed)\"; fi; fi",
"prepublishOnly": "cd nemoclaw && env -u npm_config_global -u npm_config_prefix -u npm_config_omit npm install --ignore-scripts && ./node_modules/.bin/tsc"
"prepublishOnly": "git describe --tags --match 'v*' | sed 's/^v//' > .version && test -s .version && cd nemoclaw && env -u npm_config_global -u npm_config_prefix -u npm_config_omit npm install --ignore-scripts && ./node_modules/.bin/tsc"
},
"dependencies": {
"p-retry": "^4.6.2",
Expand All @@ -26,6 +26,7 @@
"p-retry"
],
"files": [
".version",
"bin/",
"nemoclaw/dist/",
"nemoclaw/openclaw.plugin.json",
Expand Down
12 changes: 12 additions & 0 deletions src/lib/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ describe("lib/version", () => {
rmSync(join(testDir, ".version"));
});

it("regression #1239: returns .version even when package.json is stale", () => {
// npm-published tarballs ship with a stale package.json version (0.1.0)
// and a .version file stamped from the git tag at publish time. The
// installed CLI must report the .version contents, not the package.json
// semver. See issue #1239.
writeFileSync(join(testDir, "package.json"), JSON.stringify({ version: "0.1.0" }));
writeFileSync(join(testDir, ".version"), "0.0.2");
expect(getVersion({ rootDir: testDir })).toBe("0.0.2");
rmSync(join(testDir, ".version"));
writeFileSync(join(testDir, "package.json"), JSON.stringify({ version: "1.2.3" }));
});

it("returns a string", () => {
expect(typeof getVersion({ rootDir: testDir })).toBe("string");
});
Expand Down
Loading