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
path: root/test
diff options
context:
space:
mode:
authorMárton Salomváry <salomvary@gmail.com>2019-07-22 13:06:53 +0300
committerisaacs <i@izs.me>2019-08-06 22:15:09 +0300
commit24acc9fc89d99d87cc66206c6c6f7cdc82fbf763 (patch)
tree3ca929e9af9496b8aee9985078637d5f1333383d /test
parent897537ab08261fe4323b0d079047507dba62bc11 (diff)
Revert "inflate-shrinkwrap: Stop shortcircuiting tree walks with fake children"
This reverts commit 2f0c883519f17c94411dd1d9877c5666f260c12f to fix https://npm.community/t/installing-the-same-module-under-multiple-relative-paths-fails-on-linux/8863 Add (failing) test for failing relative paths Test case to shocase a bug reported here: https://npm.community/t/installing-the-same-module-under-multiple-relative-paths-fails-on-linux/8863/1 PR-URL: https://github.com/npm/cli/pull/217 Credit: @salomvary Close: #217 Reviewed-by: @isaacs
Diffstat (limited to 'test')
-rw-r--r--test/tap/install-from-local-multipath.js182
1 files changed, 182 insertions, 0 deletions
diff --git a/test/tap/install-from-local-multipath.js b/test/tap/install-from-local-multipath.js
new file mode 100644
index 000000000..83dbdadde
--- /dev/null
+++ b/test/tap/install-from-local-multipath.js
@@ -0,0 +1,182 @@
+var fs = require('graceful-fs')
+var path = require('path')
+
+var mkdirp = require('mkdirp')
+var osenv = require('osenv')
+var rimraf = require('rimraf')
+var test = require('tap').test
+
+var common = require('../common-tap')
+
+var root = common.pkg
+// Allow running this test on older commits (useful for bisecting)
+if (!root) {
+ var main = require.main.filename
+ root = path.resolve(path.dirname(main), path.basename(main, '.js'))
+}
+var pkg = path.join(root, 'parent')
+
+var EXEC_OPTS = { cwd: pkg }
+
+var parent = {
+ name: 'parent',
+ version: '0.0.0',
+ dependencies: {
+ 'child-1-1': 'file:../children/child-1-1',
+ 'child-1-2': 'file:../children/child-1-2',
+ 'child-2': 'file:../children/child-2'
+ }
+}
+
+var parentLock = {
+ 'name': 'parent',
+ 'version': '1.0.0',
+ 'lockfileVersion': 1,
+ 'requires': true,
+ 'dependencies': {
+ 'child-1-1': {
+ 'version': 'file:../children/child-1-1',
+ 'requires': {
+ 'child-2': 'file:../children/child-2'
+ }
+ },
+ 'child-1-2': {
+ 'version': 'file:../children/child-1-2',
+ 'requires': {
+ 'child-1-1': 'file:../children/child-1-1',
+ 'child-2': 'file:../children/child-2'
+ }
+ },
+ 'child-2': {
+ 'version': 'file:../children/child-2'
+ }
+ }
+}
+
+var child11 = {
+ name: 'parent',
+ version: '0.0.0',
+ 'dependencies': {
+ 'child-2': 'file:../child-2'
+ }
+}
+
+var child11Lock = {
+ 'name': 'child-1-1',
+ 'version': '1.0.0',
+ 'lockfileVersion': 1,
+ 'requires': true,
+ 'dependencies': {
+ 'child-2': {
+ 'version': 'file:../child-2'
+ }
+ }
+}
+
+var child12 = {
+ 'name': 'child-1-2',
+ 'version': '1.0.0',
+ 'dependencies': {
+ 'child-1-1': 'file:../child-1-1',
+ 'child-2': 'file:../child-2'
+ }
+}
+
+var child12Lock = {
+ 'name': 'child-1-2',
+ 'version': '1.0.0',
+ 'lockfileVersion': 1,
+ 'requires': true,
+ 'dependencies': {
+ 'child-1-1': {
+ 'version': 'file:../child-1-1',
+ 'requires': {
+ 'child-2': 'file:../child-2'
+ }
+ },
+ 'child-2': {
+ 'version': 'file:../child-2'
+ }
+ }
+}
+
+var child2 = {
+ 'name': 'child-2',
+ 'version': '1.0.0',
+ 'dependencies': {}
+}
+
+var child2Lock = {
+ 'name': 'child-2',
+ 'version': '1.0.0',
+ 'lockfileVersion': 1,
+ 'requires': true,
+ 'dependencies': {}
+}
+
+test('setup', function (t) {
+ rimraf.sync(pkg)
+ mkdirp.sync(pkg)
+ fs.writeFileSync(
+ path.join(pkg, 'package.json'),
+ JSON.stringify(parent, null, 2)
+ )
+
+ fs.writeFileSync(
+ path.join(pkg, 'package-lock.json'),
+ JSON.stringify(parentLock, null, 2)
+ )
+
+ mkdirp.sync(path.join(root, 'children', 'child-1-1'))
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-1-1', 'package.json'),
+ JSON.stringify(child11, null, 2)
+ )
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-1-1', 'package-lock.json'),
+ JSON.stringify(child11Lock, null, 2)
+ )
+
+ mkdirp.sync(path.join(root, 'children', 'child-1-2'))
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-1-2', 'package.json'),
+ JSON.stringify(child12, null, 2)
+ )
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-1-2', 'package-lock.json'),
+ JSON.stringify(child12Lock, null, 2)
+ )
+
+ mkdirp.sync(path.join(root, 'children', 'child-2'))
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-2', 'package.json'),
+ JSON.stringify(child2, null, 2)
+ )
+ fs.writeFileSync(
+ path.join(root, 'children', 'child-2', 'package-lock.json'),
+ JSON.stringify(child2Lock, null, 2)
+ )
+
+ process.chdir(pkg)
+ t.end()
+})
+
+test('\'npm install\' should install local packages', function (t) {
+ common.npm(
+ [
+ 'install', '.'
+ ],
+ EXEC_OPTS,
+ function (err, code) {
+ t.ifError(err, 'error should not exist')
+ t.notOk(code, 'npm install exited with code 0')
+ t.end()
+ }
+ )
+})
+
+test('cleanup', function (t) {
+ process.chdir(osenv.tmpdir())
+ rimraf.sync(root)
+ t.end()
+})