diff options
author | Ruy Adorno <ruyadorno@hotmail.com> | 2022-03-17 21:14:21 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-17 21:14:21 +0300 |
commit | e9a2981f55f84ff521ef597883a4e732d08ce1c1 (patch) | |
tree | c4dbf2c086ed1a69d39f6b6b5589725a8e1e29ac /workspaces/arborist/test | |
parent | 84d19210e5604775a3a413aa32cbba2c103933f2 (diff) |
fix(arborist): save workspace version (#4578)
When declaring dependencies to workspaces the common practice is to
refer to their version numbers, currently the cli adds a link reference
instead of the proper semver range when trying to install/declare as a
direct direct dependency one of its own workspaces.
This change fixes it by adding a new condition for handling workspace
edges when saving the current ideal tree.
Relates to: https://github.com/npm/cli/issues/3403
Diffstat (limited to 'workspaces/arborist/test')
-rw-r--r-- | workspaces/arborist/test/arborist/reify.js | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index f69547db4..7c22f7c69 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -894,8 +894,7 @@ t.test('saving the ideal tree', t => { a: 'git+ssh://git@github.com:foo/bar#baz', b: '', d: 'npm:c@1.x <1.9.9', - // XXX: should we remove dependencies that are also workspaces? - e: 'file:e', + e: '*', f: 'git+https://user:pass@github.com/baz/quux#asdf', g: '', h: '~1.2.3', @@ -1028,7 +1027,7 @@ t.test('saving the ideal tree', t => { a: 'github:foo/bar#baz', b: '^1.2.3', d: 'npm:c@1.x <1.9.9', - e: 'file:e', + e: '*', f: 'git+https://user:pass@github.com/baz/quux.git#asdf', g: '*', h: '~1.2.3', @@ -2045,6 +2044,15 @@ t.test('add deps to workspaces', async t => { t.matchSnapshot(require(path + '/packages/a/package.json'), 'package.json a') t.matchSnapshot(require(path + '/package-lock.json'), 'lockfile') }) + + t.test('add a to root', async t => { + const path = t.testdir(fixture) + await reify(path) + const tree = await reify(path, { add: ['a'], lockfileVersion: 3 }) + t.matchSnapshot(printTree(tree), 'returned tree') + t.matchSnapshot(require(path + '/package.json'), 'package.json added workspace as dep') + t.matchSnapshot(require(path + '/package-lock.json'), 'lockfile added workspace as dep') + }) }) t.test('reify audit only workspace deps when reifying workspace', async t => { |