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
Support save-exact true #4471
Support save-exact true #4471
Conversation
This should be so obvious: if I set The yarn parser should also allow to set |
Agreed.
This is not true. You can set it to an empty string. |
It should definitely be backwards compatible, otherwise this change would require a major version upgrade. |
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.
Thanks for the PR!
Tests are passing.
This is not enough :) You also need to add a new test(s) to test the new behavior.
src/cli/commands/add.js
Outdated
@@ -83,7 +83,7 @@ export class Add extends Install { | |||
let prefix; | |||
if (tilde) { | |||
prefix = '~'; | |||
} else if (exact) { | |||
} else if (exact || Boolean(this.config.getOption('save-exact'))) { |
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 think it is better to do
const exact = this.flags.exact || Boolean(this.config.getOption('save-exact'));
const tilde = this.flags.tilde;
above. save-exact
should take precedence over save-prefix
option.
Really? My colleague got that error when tried to set Maybe it was his fault or caused by some kind of other wrong configuration... In this case 👍 |
@BYK True :) I might need some pointers on how to test the |
9b3e035
to
e0f3cab
Compare
I added a test & changed the logic to be backward compatible. const exact =
this.flags.exact ||
Boolean(this.config.getOption('save-exact')) ||
String(this.config.getOption('save-prefix')) === ''; The |
e0f3cab
to
ce63a90
Compare
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.
Nice, thanks a lot! Also, sorry for the late response. The patch looks good but tests need some small improvements and using a variable for the config value would be great.
After those, I don't see any reason to not merge this.
@@ -0,0 +1 @@ | |||
yarn-offline-mirror=./mirror-for-offline |
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 a separate file? Let's move this into .yarnrc
below.
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.
Honestly, I just copied install-no-strict-all
and just added .yarnrc
:)
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.
Maybe actually this is not needed at all?
@@ -0,0 +1,5 @@ | |||
{ | |||
"dependencies": { | |||
"mime-types": "^2.0.0" |
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 don't think you need this at all since you already do yarn add left-pad
in the test
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 think I can remove package.json
& mirror-for-offline
folder too then?
src/cli/commands/add.js
Outdated
const exact = | ||
this.flags.exact || | ||
Boolean(this.config.getOption('save-exact')) || | ||
String(this.config.getOption('save-prefix')) === ''; |
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.
Assigning this to a variable like configPrefix
might be good since it is now used here and also below.
ce63a90
to
51f26e3
Compare
51f26e3
to
8f39f6b
Compare
This change will decrease the build size from 9.69 MB to 9.69 MB, a decrease of 1.75 KB (0%)
|
1 similar comment
This change will decrease the build size from 9.69 MB to 9.69 MB, a decrease of 1.75 KB (0%)
|
@BYK can you have a look at travis, I think it's failing because of disk/memory issues or something. all the errors are like this
|
@@ -0,0 +1,2 @@ | |||
yarn-offline-mirror "./mirror-for-offline" |
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.
Offline mirror is for not using the internet to install packages during test AFAIK.
This is probably due to the RAMDISK on OS X builds. If it fails again, I'll edit your patch and increase the size. |
Merged! Thanks a lot for helping us with this ❤️ |
Thanks @BYK 😊 |
**Summary** Fixes yarnpkg#4343. Currently there is no way to remove the package prefix inside `.yarnrc` file, this PR add support for `save-exact` in `.yarnrc` as discussed in yarnpkg#4343. Full credit goes to @jambonrose ``` save-exact true ``` One small thing, should `yarn` be backwards compatible with the old behavior which is `save-prefix ''`? We can just add an extra check here for do this. What do you think @BYK? ```js } else if (exact || Boolean(this.config.getOption('save-exact')) || Boolean(this.config.getOption('save-prefix'))) { ``` **Test plan** New unit test.
Summary
Fixes #4343. Currently there is no way to remove the package prefix inside
.yarnrc
file, this PR add support forsave-exact
in.yarnrc
as discussed in #4343. Full credit goes to @jambonroseOne small thing, should
yarn
be backwards compatible with the old behavior which issave-prefix ''
? We can just add an extra check here for do this. What do you think @BYK?Test plan
New unit test.