-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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(cli): fail when yarn add
ing Github package with no version (#5292)
#5318
Conversation
@bestander please review at your convenience. It looks like most of the testing for these helper libraries is done through issuing actual cli commands, so hopefully this test coverage is sufficient. Thanks for all your help! |
@@ -473,7 +473,7 @@ export default class Git implements GitRefResolvingInterface { | |||
}); | |||
if (!resolvedResult) { | |||
throw new MessageError( | |||
this.reporter.lang('couldntFindMatch', version, Object.keys(refs).join(','), this.gitUrl.repository), | |||
this.reporter.lang('couldntFindMatch', version, Array.from(refs.keys()).join(','), this.gitUrl.repository), |
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.
refs
is a Map
which always returns an empty array with Object.keys()
} catch (err) { | ||
message = err.message; | ||
} | ||
expect(message).toEqual(expect.stringContaining('invalid package version')); |
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.
Would be preferable to use .rejects
and assert on the error message using toThrow
or the like, but it looks like this is still problematic: jestjs/jest#3601
Thank you @mhchen ! |
@mhchen great work! Thank you for following it through and doing tests. |
Summary
Running
yarn add
to install from a Github repo that has a package.json with no version succeeds, but then all furtheryarn
operations fail due to failing checks forversion
s in dependencies. As well, per npm, the install method should not succeed at all. This PR causesyarn add
to fail ifversion
is not properly formatted as a semver.Fixes #5292
Test plan
Running:
Produces the following output: