Skip to content

Commit 24acc9f

Browse files
salomvaryisaacs
authored andcommitted
Revert "inflate-shrinkwrap: Stop shortcircuiting tree walks with fake children"
This reverts commit 2f0c883 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: #217 Credit: @salomvary Close: #217 Reviewed-by: @isaacs
1 parent 897537a commit 24acc9f

File tree

2 files changed

+183
-1
lines changed

2 files changed

+183
-1
lines changed

lib/install/inflate-shrinkwrap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ function makeFakeChild (name, topPath, tree, sw, requested) {
167167
}
168168
const child = createChild({
169169
package: pkg,
170-
loaded: false,
170+
loaded: true,
171171
parent: tree,
172172
children: [],
173173
fromShrinkwrap: requested,
+182
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
var fs = require('graceful-fs')
2+
var path = require('path')
3+
4+
var mkdirp = require('mkdirp')
5+
var osenv = require('osenv')
6+
var rimraf = require('rimraf')
7+
var test = require('tap').test
8+
9+
var common = require('../common-tap')
10+
11+
var root = common.pkg
12+
// Allow running this test on older commits (useful for bisecting)
13+
if (!root) {
14+
var main = require.main.filename
15+
root = path.resolve(path.dirname(main), path.basename(main, '.js'))
16+
}
17+
var pkg = path.join(root, 'parent')
18+
19+
var EXEC_OPTS = { cwd: pkg }
20+
21+
var parent = {
22+
name: 'parent',
23+
version: '0.0.0',
24+
dependencies: {
25+
'child-1-1': 'file:../children/child-1-1',
26+
'child-1-2': 'file:../children/child-1-2',
27+
'child-2': 'file:../children/child-2'
28+
}
29+
}
30+
31+
var parentLock = {
32+
'name': 'parent',
33+
'version': '1.0.0',
34+
'lockfileVersion': 1,
35+
'requires': true,
36+
'dependencies': {
37+
'child-1-1': {
38+
'version': 'file:../children/child-1-1',
39+
'requires': {
40+
'child-2': 'file:../children/child-2'
41+
}
42+
},
43+
'child-1-2': {
44+
'version': 'file:../children/child-1-2',
45+
'requires': {
46+
'child-1-1': 'file:../children/child-1-1',
47+
'child-2': 'file:../children/child-2'
48+
}
49+
},
50+
'child-2': {
51+
'version': 'file:../children/child-2'
52+
}
53+
}
54+
}
55+
56+
var child11 = {
57+
name: 'parent',
58+
version: '0.0.0',
59+
'dependencies': {
60+
'child-2': 'file:../child-2'
61+
}
62+
}
63+
64+
var child11Lock = {
65+
'name': 'child-1-1',
66+
'version': '1.0.0',
67+
'lockfileVersion': 1,
68+
'requires': true,
69+
'dependencies': {
70+
'child-2': {
71+
'version': 'file:../child-2'
72+
}
73+
}
74+
}
75+
76+
var child12 = {
77+
'name': 'child-1-2',
78+
'version': '1.0.0',
79+
'dependencies': {
80+
'child-1-1': 'file:../child-1-1',
81+
'child-2': 'file:../child-2'
82+
}
83+
}
84+
85+
var child12Lock = {
86+
'name': 'child-1-2',
87+
'version': '1.0.0',
88+
'lockfileVersion': 1,
89+
'requires': true,
90+
'dependencies': {
91+
'child-1-1': {
92+
'version': 'file:../child-1-1',
93+
'requires': {
94+
'child-2': 'file:../child-2'
95+
}
96+
},
97+
'child-2': {
98+
'version': 'file:../child-2'
99+
}
100+
}
101+
}
102+
103+
var child2 = {
104+
'name': 'child-2',
105+
'version': '1.0.0',
106+
'dependencies': {}
107+
}
108+
109+
var child2Lock = {
110+
'name': 'child-2',
111+
'version': '1.0.0',
112+
'lockfileVersion': 1,
113+
'requires': true,
114+
'dependencies': {}
115+
}
116+
117+
test('setup', function (t) {
118+
rimraf.sync(pkg)
119+
mkdirp.sync(pkg)
120+
fs.writeFileSync(
121+
path.join(pkg, 'package.json'),
122+
JSON.stringify(parent, null, 2)
123+
)
124+
125+
fs.writeFileSync(
126+
path.join(pkg, 'package-lock.json'),
127+
JSON.stringify(parentLock, null, 2)
128+
)
129+
130+
mkdirp.sync(path.join(root, 'children', 'child-1-1'))
131+
fs.writeFileSync(
132+
path.join(root, 'children', 'child-1-1', 'package.json'),
133+
JSON.stringify(child11, null, 2)
134+
)
135+
fs.writeFileSync(
136+
path.join(root, 'children', 'child-1-1', 'package-lock.json'),
137+
JSON.stringify(child11Lock, null, 2)
138+
)
139+
140+
mkdirp.sync(path.join(root, 'children', 'child-1-2'))
141+
fs.writeFileSync(
142+
path.join(root, 'children', 'child-1-2', 'package.json'),
143+
JSON.stringify(child12, null, 2)
144+
)
145+
fs.writeFileSync(
146+
path.join(root, 'children', 'child-1-2', 'package-lock.json'),
147+
JSON.stringify(child12Lock, null, 2)
148+
)
149+
150+
mkdirp.sync(path.join(root, 'children', 'child-2'))
151+
fs.writeFileSync(
152+
path.join(root, 'children', 'child-2', 'package.json'),
153+
JSON.stringify(child2, null, 2)
154+
)
155+
fs.writeFileSync(
156+
path.join(root, 'children', 'child-2', 'package-lock.json'),
157+
JSON.stringify(child2Lock, null, 2)
158+
)
159+
160+
process.chdir(pkg)
161+
t.end()
162+
})
163+
164+
test('\'npm install\' should install local packages', function (t) {
165+
common.npm(
166+
[
167+
'install', '.'
168+
],
169+
EXEC_OPTS,
170+
function (err, code) {
171+
t.ifError(err, 'error should not exist')
172+
t.notOk(code, 'npm install exited with code 0')
173+
t.end()
174+
}
175+
)
176+
})
177+
178+
test('cleanup', function (t) {
179+
process.chdir(osenv.tmpdir())
180+
rimraf.sync(root)
181+
t.end()
182+
})

0 commit comments

Comments
 (0)