Skip to content

Commit

Permalink
added another test
Browse files Browse the repository at this point in the history
  • Loading branch information
bestander committed Jun 24, 2017
1 parent b02b5ad commit 4d71984
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 2 deletions.
21 changes: 20 additions & 1 deletion __tests__/commands/install/integration-deduping.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ test.concurrent('install should not copy node_modules when hardlinking', (): Pro
// A@1 -> B@1 -> C@1
// -> C@2
// B@2
// C@2
// C@3
// D@1 -> B@1 (hardlink) -> C@1 (hardlink)
// -> C@2
return runInstall({linkDuplicates: true}, 'hardlink-collision', async config => {
Expand All @@ -238,3 +238,22 @@ test.concurrent('install should not copy node_modules when hardlinking', (): Pro
expect(a_1.ino).toEqual(d_1.ino);
});
});

test.concurrent('install should not hardlink full package structure', (): Promise<void> => {
// https://github.com/yarnpkg/yarn/issues/2734
// A@1 -> B@1 -> C@1
// -> C@2
// B@2
// C@3
// D@1 -> B@1 (hardlink)
// -> C@1 (hardlink)
return runInstall({linkDuplicates: true}, 'hardlink-collision-2', async config => {
let a_1 = await fs.stat(path.join(config.cwd, 'node_modules/a/node_modules/b/package.json'));
let d_1 = await fs.stat(path.join(config.cwd, 'node_modules/d/node_modules/b/package.json'));
expect(a_1.ino).toEqual(d_1.ino);
a_1 = await fs.stat(path.join(config.cwd, 'node_modules/a/node_modules/b/node_modules/c/package.json'));
d_1 = await fs.stat(path.join(config.cwd, 'node_modules/d/node_modules/c/package.json'));
expect(a_1.ino).toEqual(d_1.ino);
expect(await fs.exists(path.join(config.cwd, 'node_modules/d/node_modules/b/node_modules/c/package.json'))).toBe(false);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "a",
"version": "1.0.0",
"dependencies": {
"b": "file:../b-1",
"c": "file:../c-2"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "b",
"version": "1.0.0",
"dependencies": {
"c": "file:../c-1"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "b",
"version": "2.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "c",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "c",
"version": "2.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "c",
"version": "3.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "a",
"version": "2.0.0",
"dependencies": {
"b": "file:../b-1"
}
}
8 changes: 8 additions & 0 deletions __tests__/fixtures/install/hardlink-collision-2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dependencies": {
"a": "file:deps/a-1",
"b": "file:deps/b-2",
"c": "file:deps/c-3",
"d": "file:deps/d-1"
}
}
1 change: 0 additions & 1 deletion src/util/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,6 @@ async function buildActionsForHardlink(

// push all files to queue
invariant(srcFiles, 'src files not initialised');
// hardlinking is per package, not going into sub packages
srcFiles = srcFiles.filter(f => f !== 'node_modules');
let remaining = srcFiles.length;
if (!remaining) {
Expand Down

0 comments on commit 4d71984

Please sign in to comment.