-
-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cli.js is reading incorrect package.json file for version #456
Comments
Thanks for the bug report! I think a more appropriate fix would be to use a module-relative URL...e.g. something like:
|
andysturrock
added a commit
to andysturrock/ohm
that referenced
this issue
Aug 11, 2023
From ohmjs#456 Parse ohm's package.json file to obtain the version. cli.js was parsing the package.json in the current directory to obtain the package version. It now parses its own package.json file, not the one from the project that is using ohm.
Yep that makes more sense. PR #458 created |
pdubroy
pushed a commit
that referenced
this issue
Aug 16, 2023
From #456 Parse ohm's package.json file to obtain the version. cli.js was parsing the package.json in the current directory to obtain the package version. It now parses its own package.json file, not the one from the project that is using ohm. Co-authored-by: Andy Sturrock <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 6 of cli.js reads the package.json file from the current directory:
const {version} = JSON.parse(fs.readFileSync('./package.json'));
If that package.json file does not have a version key then
npx ohm generateBundles
fails with:TypeError: Cannot read properties of undefined (reading 'option')
If the local file does have a version then the -v flag will return that, rather than the version of ohmjs.
To get the current version of ohmjs, I think it should be:
const {version} = JSON.parse(fs.readFileSync('./node_modules/@ohm-js/cli/package.json'));
If you agree I am happy to submit a PR.
The text was updated successfully, but these errors were encountered: