-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
fix version inference regression #445
Conversation
// Search package.json files to infer name and version from | ||
getPackageInfo(props, dir, function (err, result) { | ||
if (err) { | ||
// `get-package-info` exploded looking for `electron`. Try `electron-prebuilt` instead |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it also error if both productName
and name
were missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is electron
different from electron-prebuilt
? If they're the same, you can just do props.push(['dependencies.electron', 'dependencies.electron-prebuilt', 'devDependencies.electron', 'devDependencies.electron-prebuilt'])
, which will resolve to whichever it finds first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
electron
is preferred over electron-prebuilt
(the former is the eventual replacement for the latter).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then it would be props.push(['dependencies.electron', 'devDependencies.electron', 'dependencies.electron-prebuilt', 'devDependencies.electron-prebuilt'])
. Either way, you can avoid a 2nd getPackageInfo
call. I think that's all that was needed to add support for infering from electron
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pushing all of them into the same props
array was what I started with, but then we don't know if the resulting version was derived from electron
or electron-prebuilt
. Hence the separation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to know which package it came from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because resolve
needs a path:
resolve(packageName, {
basedir: path.dirname(result.source[`dependencies.${packageName}`].src)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, d'oh. I forgot about that. In that case it might be better to make a trivial PR to get-package-info
that can add the property name to result.source
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and did that myself. Working on a PR for this branch to clean it up accordingly.
Now using ES6 string interpolation. I was avoiding it because I thought maybe this project needed to work on older versions of node. But no!
|
Yep. And I'm paying for that decision because you can't actually enforce a Node engine version as far as I know. 😢 |
Thanks for the patch, @rahatarmanahmed. I merged #446. If this passes CI, let's ship it! |
Sounds good. Just needs a NEWS entry and some rebasing. |
There's that error again 😞 |
34b4249
to
c6b4c90
Compare
261b9e5
to
ec614bf
Compare
Added news, squashed. Last CI run passed on all six builds. This is ready. :fingers_crossed: |
Rerunning that build. Pretty sure this is just more flakiness. |
Doesn't really fix #441 then, right? |
@malept You can be really mean and do something like this in if (parseInt(process.versions.node[0], 10) < 4) {
throw new BigNastyError('Get a better node version plz')
} |
@MarshallOfSound I would, but I think I get a SyntaxError before that can be executed. |
The flakiness on Travis has not been unique to Node 4. I was seeing it on all node versions and platforms. I think this is ready to 🚢 |
As far as I can tell, it's always been with that specific test, though. Which is really what #441 is about. |
@malept what do you say we ship this since it is definitely an improvement to a known bug in the latest release? We can address the flakiness if it turns out to be an issue. |
Sure. The only thing I object to in this PR is the assertion that it fixes #441. |
Fixes #441
This brings
get-package-info
back into the mix, so directories are properly traversed forpackage.json
files containingelectron
orelectron-prebuilt
. The work is broken up into two functions now to work around theresolve
issue that causes an error to be thrown when a given set of props are not found.cc @malept @kevinsawicki