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

Warn if a resolution tries to change a top-level dependency #8315

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions __tests__/commands/install/resolutions.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ test.concurrent('should warn when resolution entries are incorrrect or incompati
expect(error).toContain('Resolution field "left-pad@1.0.0" is incompatible with requested version "left-pad@~1.1.0');
expect(error).toContain('Resolution field "wrongversion" has an invalid version entry and may be ignored');
expect(error).toContain('Resolution field "invalidname/" does not end with a valid package name and will be ignored');
expect(error).toContain('A resolution appears to attempt to change a top level dependency');
});

test.concurrent('install with resolutions should correctly install simple scoped packages', (): Promise<void> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"resolutions": {
"c/**/left-pad": "1.0.0",
"invalidname/": "1.0.0",
"**/left-pad": "wrongversion"
"**/left-pad": "wrongversion",
"left-pad": "1.0.0"
}
}
4 changes: 4 additions & 0 deletions src/resolution-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export default class ResolutionMap {
for (const globPattern in resolutions) {
const info = this.parsePatternInfo(globPattern, resolutions[globPattern]);

if (!/[\/\*]/.test(globPattern)) {
this.reporter.warn(`A resolution appears to attempt to change a top level dependency`);
}

if (info) {
const resolution = this.resolutionsByPackage[info.name] || [];
this.resolutionsByPackage[info.name] = [...resolution, info];
Expand Down