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

[cli] Fix if dependency is resolved npm package #4298

Merged
merged 2 commits into from Apr 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions cli/src/lib/npm/__tests__/npmProjectUtils-test.js
@@ -0,0 +1,21 @@
// @flow
import {mergePackageJsonDependencies} from '../npmProjectUtils';

describe('npmProjectUtils', () => {
describe('mergePackageJsonDependencies', () => {
it('does not break with deps that resolve with `npm:...', () => {
expect(
mergePackageJsonDependencies(
{
'react-intl-next': 'npm:react@16.8.0',
},
{
'react-intl-next': 'npm:react@16.8.0',
},
),
).toEqual({
'react-intl-next': 'npm:react@16.8.0',
});
});
});
});
9 changes: 8 additions & 1 deletion cli/src/lib/npm/npmProjectUtils.js
Expand Up @@ -186,7 +186,14 @@ export function mergePackageJsonDependencies(
const result = {...a};
for (const dep of Object.keys(b)) {
const version = b[dep];
if (a[dep] != null && !intersects(result[dep], version)) {
let doesIntersect;
try {
doesIntersect = intersects(result[dep], version);
} catch (e) {
doesIntersect = result[dep] === version;
}

if (a[dep] != null && !doesIntersect) {
console.log(
colors.yellow(
"\t Conflicting versions for '%s' between '%s' and '%s'",
Expand Down