Skip to content

Commit 387fa41

Browse files
committed
fix(npm): read version from package.json instead of hard-coding
The release workflow runs 'npm version $tag' to bump package.json from the git tag, but install.js had its own hard-coded VERSION = '0.3.0' constant that nothing was updating. So at release time the package metadata says (e.g.) 0.4.0 while the postinstall still downloads the 0.3.0 binary archive, silently shipping an older binary to anyone running 'npm install -g stacklit'. Reading the version from ./package.json makes that release-time bump the single source of truth. No new dependency, no extra release step, and the version stays correct for pre-releases ('0.4.0-beta.1' style) since goreleaser uses the same scheme for its archive names.
1 parent 4169ebf commit 387fa41

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

npm/install.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ const path = require('path');
44
const https = require('https');
55
const { execFileSync } = require('child_process');
66

7-
const VERSION = '0.3.0';
7+
// Read the version from package.json so the npm publish workflow's
8+
// `npm version <tag>` bump is the single source of truth. Previously this was
9+
// a hard-coded constant that drifted from package.json on every release,
10+
// causing the postinstall to pull an outdated binary archive.
11+
const VERSION = require('./package.json').version;
812
const REPO = 'glincker/stacklit';
913

1014
const PLATFORM_MAP = {

0 commit comments

Comments
 (0)