Yarn: Bug: upgrade with pattern upgrades all packages

Created on 12 Apr 2018  路  5Comments  路  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
yarn upgrade --pattern seemingly ignores the pattern and upgrades all.

If the current behavior is a bug, please provide the steps to reproduce.

$ yarn outdated
yarn outdated v1.5.1
info Color legend : 
 "<red>"    : Major Update backward-incompatible updates 
 "<yellow>" : Minor Update backward-compatible features 
 "<green>"  : Patch Update backward-compatible bug fixes
Package                               Current Wanted Latest Package Type    URL                                                        
@fortawesome/fontawesome-free-brands  5.0.9   5.0.10 5.0.10 dependencies    https://fontawesome.com                                    
@fortawesome/fontawesome-free-regular 5.0.9   5.0.10 5.0.10 dependencies    https://fontawesome.com                                    
@fortawesome/fontawesome-free-solid   5.0.9   5.0.10 5.0.10 dependencies    https://fontawesome.com                                    
bootstrap                             4.0.0   4.1.0  4.1.0  dependencies    https://getbootstrap.com  

$ yarn upgrade --pattern fontawesome
...
info Direct dependencies
鈹溾攢 @fortawesome/[email protected]
鈹溾攢 @fortawesome/[email protected]
鈹溾攢 @fortawesome/[email protected]
鈹溾攢 [email protected]
...

$ yarn outdated | grep bootstrap
<no output>

@philquinn, am I understanding this feature incorrectly? https://github.com/yarnpkg/yarn/pull/4610

What is the expected behavior?
--pattern should restrict upgraded packages to only those that match the pattern

Please mention your node.js, yarn and operating system version.
Node 9.11.1
yarn 1.5.1
macOS 10.13.4

cat-bug high-priority triaged

All 5 comments

The worst part is we even have a unit test for --pattern, but it was poorly written and passes when all packages upgrade 馃槥

Thanks for reporting this. I'll try to track down when/why this broke.

Hey @swrobel , I can reproduce this. It appears the part which filters on the pattern is unreachable unless a package is also passed. So doing yarn upgrade some-package-name --pattern fontawesome would get what you want I think. But thats a bug. It should work without the package just the same. I will try do a fix for this as soon as I can.

@philquinn I have a fix written and passing a unit test. I'm just trying to clean up some rather ugly looking conditionals code before I make a PR...


_edit_

I also need to fix one other aspect of the tests, which is that it checks the version of:

    await expectInstalledDependency(config, 'is-negative-zero', '^1.0.0', '1.0.0');

but is-negative-zero has no versions never than 1.0.0 so even when it "upgrades all" the test still passes.

Ah really sorry @rally25rs I started working on this straight away, didn't see you were also.
I also noticed the is-negative-zero issue, I chose array-union as an alternative as it was referenced in the same file. Along with the left-pad being just the wrong check, my bad.
I have a PR in with the fix. It would be great if you could review it.

@philquinn 馃憦 on the quick fix!

Was this page helpful?
0 / 5 - 0 ratings