From 7ce2234ba6e3c92a8fed48c500e6988ac3246f2a Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 6 Apr 2022 18:21:56 +1200 Subject: [PATCH 1/2] fix resolved deps --- .../lib/npm/__tests__/npmProjectUtils-test.js | 21 +++++++++++++++++++ cli/src/lib/npm/npmProjectUtils.js | 9 +++++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 cli/src/lib/npm/__tests__/npmProjectUtils-test.js diff --git a/cli/src/lib/npm/__tests__/npmProjectUtils-test.js b/cli/src/lib/npm/__tests__/npmProjectUtils-test.js new file mode 100644 index 0000000000..3422d66f6c --- /dev/null +++ b/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', + }); + }); + }); +}); diff --git a/cli/src/lib/npm/npmProjectUtils.js b/cli/src/lib/npm/npmProjectUtils.js index 3755262b55..c46a5c9056 100644 --- a/cli/src/lib/npm/npmProjectUtils.js +++ b/cli/src/lib/npm/npmProjectUtils.js @@ -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 = false; + } + + if (a[dep] != null && !doesIntersect) { console.log( colors.yellow( "\t Conflicting versions for '%s' between '%s' and '%s'", From 4f40898406cd47a3cfa23fc7b995c1ea02ef1328 Mon Sep 17 00:00:00 2001 From: Brian Chen Date: Wed, 6 Apr 2022 19:30:27 +1200 Subject: [PATCH 2/2] correct a bit of logic to not spew as error --- cli/src/lib/npm/npmProjectUtils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/src/lib/npm/npmProjectUtils.js b/cli/src/lib/npm/npmProjectUtils.js index c46a5c9056..8132bc075b 100644 --- a/cli/src/lib/npm/npmProjectUtils.js +++ b/cli/src/lib/npm/npmProjectUtils.js @@ -190,7 +190,7 @@ export function mergePackageJsonDependencies( try { doesIntersect = intersects(result[dep], version); } catch (e) { - doesIntersect = false; + doesIntersect = result[dep] === version; } if (a[dep] != null && !doesIntersect) {