Skip to content

Commit

Permalink
[cli] Fix if dependency is resolved npm package (#4298)
Browse files Browse the repository at this point in the history
* fix resolved deps

* correct a bit of logic to not spew as error
  • Loading branch information
Brianzchen committed Apr 6, 2022
1 parent ea501ef commit c9e7193
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
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

0 comments on commit c9e7193

Please sign in to comment.