Simplify package.json inference
See original GitHub issueFollowing up on https://github.com/electron-userland/electron-packager/pull/449#issuecomment-240865736
Currently there’s a bit of code in index.js
that uses get-package-info
to look for package.json files from which to infer default values for electron version, product name, etc. This technique of recursing up directories can produce unpredictable results depending on the directory structure of a given user.
As @malept said:
Not that I want to drag this PR out any longer, but should we have a test for the case where no app-version is specified and (for some reason) there is no version in any of the package.json files found?
Looking for the first parent package.json file instead of all parent package.json files will enable us to reliably test that scenario. Writing up this issue because I came across a battle-tested package that does what we want: https://www.npmjs.com/package/find-root
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (11 by maintainers)
Top GitHub Comments
Ok, published
1.0.0
ofget-package-info
, which now returns a better error that lets us know when props can’t be found.From the README:
I’ll work on a PR using this new info later tonight.
There have been a couple of pull requests that make adding
electron
(FKAelectron-prebuilt
) not required to be set independencies
ordevDependencies
, nor set via--version
(although no one’s actually finished any of the PRs). I’m a bit conflicted about whether that is a good default. Offhand, it seems dangerous, given that basically defaults the dependency to"electron": "*"
.