Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornlf <quitlahok@gmail.com>2022-03-24 21:18:21 +0300
committerLuke Karrys <luke@lukekarrys.com>2022-03-28 23:19:27 +0300
commit6f9cb490e7299976c43c6a118036c130671fe188 (patch)
tree0320e3f944219959e61f314fb16350a993779626 /workspaces/arborist/test
parent6a4c8ff89acc98409060f5aa55b2f1a795a6b66c (diff)
fix(arborist): handle link nodes in old lockfiles correctly
Diffstat (limited to 'workspaces/arborist/test')
-rw-r--r--workspaces/arborist/test/arborist/build-ideal-tree.js20
-rw-r--r--workspaces/arborist/test/fixtures/old-lock-with-link/link-dep/package.json4
-rw-r--r--workspaces/arborist/test/fixtures/old-lock-with-link/package-lock.json11
-rw-r--r--workspaces/arborist/test/fixtures/old-lock-with-link/package.json7
4 files changed, 42 insertions, 0 deletions
diff --git a/workspaces/arborist/test/arborist/build-ideal-tree.js b/workspaces/arborist/test/arborist/build-ideal-tree.js
index e718b0b58..d869c686e 100644
--- a/workspaces/arborist/test/arborist/build-ideal-tree.js
+++ b/workspaces/arborist/test/arborist/build-ideal-tree.js
@@ -1163,6 +1163,26 @@ This is a one-time fix-up, please be patient...
])
})
+t.test('inflating a link node in an old lockfile skips registry', async t => {
+ const checkLogs = warningTracker()
+ const path = resolve(fixtures, 'old-lock-with-link')
+ const arb = new Arborist({ path, ...OPT, registry: 'http://invalid.host' })
+ const tree = await arb.buildIdealTree()
+ t.matchSnapshot(printTree(tree))
+ t.strictSame(checkLogs(), [
+ [
+ 'warn',
+ 'old lockfile',
+ `
+The package-lock.json file was created with an old version of npm,
+so supplemental metadata must be fetched from the registry.
+
+This is a one-time fix-up, please be patient...
+`,
+ ],
+ ])
+})
+
t.test('warn for ancient lockfile, even if we use v1', async t => {
const checkLogs = warningTracker()
const path = resolve(fixtures, 'sax')
diff --git a/workspaces/arborist/test/fixtures/old-lock-with-link/link-dep/package.json b/workspaces/arborist/test/fixtures/old-lock-with-link/link-dep/package.json
new file mode 100644
index 000000000..0bb2ef11a
--- /dev/null
+++ b/workspaces/arborist/test/fixtures/old-lock-with-link/link-dep/package.json
@@ -0,0 +1,4 @@
+{
+ "name": "link-dep",
+ "version": "1.0.0"
+}
diff --git a/workspaces/arborist/test/fixtures/old-lock-with-link/package-lock.json b/workspaces/arborist/test/fixtures/old-lock-with-link/package-lock.json
new file mode 100644
index 000000000..f004bc625
--- /dev/null
+++ b/workspaces/arborist/test/fixtures/old-lock-with-link/package-lock.json
@@ -0,0 +1,11 @@
+{
+ "name": "old-lock-with-link",
+ "version": "1.0.0",
+ "lockfileVersion": 1,
+ "requires": true,
+ "dependencies": {
+ "link-dep": {
+ "version": "file:link-dep"
+ }
+ }
+}
diff --git a/workspaces/arborist/test/fixtures/old-lock-with-link/package.json b/workspaces/arborist/test/fixtures/old-lock-with-link/package.json
new file mode 100644
index 000000000..85c242456
--- /dev/null
+++ b/workspaces/arborist/test/fixtures/old-lock-with-link/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "old-lock-with-link",
+ "version": "1.0.0",
+ "dependencies": {
+ "link-dep": "file:./link-dep"
+ }
+}