Repository navigation
Read CLI version from package.json - #4
Conversation
Balanov
left a comment
There was a problem hiding this comment.
Thank you for picking this up, and for making the change as small as it can be.
I checked the surrounding code before approving. ROOT is already resolved two lines above the point where the version is read, and it points at the repository root rather than at bin/, so path.join(ROOT, "package.json") resolves to the right file both from a checkout and from an installed package. Reading it with readFileSync at module load keeps the CLI synchronous, which matters here: until --version is called from the benchmark startup check and from the help text, and neither should have to await anything.
One note on the order of the declarations: VERSION is now derived, so it has to come after ROOT. Your patch does that. HELP interpolates VERSION, so the help banner follows the same value as --version.
The remaining item from the issue is the regression test: a test that asserts the reported version equals the version field of package.json, so the next release cannot drift again. That is not in this branch, so I am leaving the issue open for it rather than closing it here. Please feel free to send it as a follow-up - a failing drift test is a small, self-contained change, and it is exactly the kind of first contribution this repository wants.
Merging this now.
Fixes #1
until --versionnow reads the version from package.json instead of a hardcoded constant, so it reports 0.3.0 and stays in sync with future releases.