Skip to content
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

Merged
merged 1 commit into from
Aug 11, 2016
Merged

Conversation

zeke
Copy link
Contributor

@zeke zeke commented Aug 8, 2016

Fixes #441

This brings get-package-info back into the mix, so directories are properly traversed for package.json files containing electron or electron-prebuilt. The work is broken up into two functions now to work around the resolve issue that causes an error to be thrown when a given set of props are not found.

cc @malept @kevinsawicki

// 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
Copy link
Member

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?

Copy link
Contributor

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.

Copy link
Member

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).

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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)
}

Copy link
Contributor

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

Copy link
Contributor

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.

@zeke
Copy link
Contributor Author

zeke commented Aug 8, 2016

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!

  "engines": {
    "node": ">= 4.0"
  }

@malept
Copy link
Member

malept commented Aug 8, 2016

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. 😢

@zeke
Copy link
Contributor Author

zeke commented Aug 9, 2016

Thanks for the patch, @rahatarmanahmed. I merged #446. If this passes CI, let's ship it!

@malept
Copy link
Member

malept commented Aug 9, 2016

Sounds good. Just needs a NEWS entry and some rebasing.

@malept
Copy link
Member

malept commented Aug 9, 2016

There's that error again 😞

@zeke zeke force-pushed the fix-version-inference-regression branch from 34b4249 to c6b4c90 Compare August 10, 2016 18:46
@zeke zeke force-pushed the fix-version-inference-regression branch from 261b9e5 to ec614bf Compare August 10, 2016 21:49
@zeke
Copy link
Contributor Author

zeke commented Aug 10, 2016

Added news, squashed. Last CI run passed on all six builds. This is ready. :fingers_crossed:

@malept
Copy link
Member

malept commented Aug 10, 2016

@zeke
Copy link
Contributor Author

zeke commented Aug 10, 2016

Rerunning that build. Pretty sure this is just more flakiness.

@malept
Copy link
Member

malept commented Aug 10, 2016

Doesn't really fix #441 then, right?

@MarshallOfSound
Copy link
Member

Yep. And I'm paying for that decision because you can't actually enforce a Node engine version as far as I know.

@malept You can be really mean and do something like this in index.js

if (parseInt(process.versions.node[0], 10) < 4) {
  throw new BigNastyError('Get a better node version plz')
}

@malept
Copy link
Member

malept commented Aug 11, 2016

@MarshallOfSound I would, but I think I get a SyntaxError before that can be executed.

@zeke
Copy link
Contributor Author

zeke commented Aug 11, 2016

Doesn't really fix #441 then, right?

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 🚢

@malept
Copy link
Member

malept commented Aug 11, 2016

As far as I can tell, it's always been with that specific test, though. Which is really what #441 is about.

@zeke
Copy link
Contributor Author

zeke commented Aug 11, 2016

@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.

@malept
Copy link
Member

malept commented Aug 11, 2016

Sure. The only thing I object to in this PR is the assertion that it fixes #441.

@zeke zeke merged commit d5f1bd7 into master Aug 11, 2016
@zeke zeke deleted the fix-version-inference-regression branch August 11, 2016 21:38
@malept malept modified the milestone: 7.6.0 Aug 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix infer electron test introduced in 7.5.0
4 participants