Skip to content

Commit

Permalink
Add test to check that linker does not recreate folders (fails for now)
Browse files Browse the repository at this point in the history
  • Loading branch information
larixer committed Apr 14, 2020
1 parent 450419f commit c1bd0f5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,39 @@ describe('Node_Modules', () => {
},
),
);

test(`should not recreated folders when package is updated`,
makeTemporaryEnv(
{
private: true,
dependencies: {
[`no-deps`]: `1.0.0`,
},
},
async ({path, run}) => {
await writeFile(npath.toPortablePath(`${path}/.yarnrc.yml`), `
nodeLinker: "node-modules"
`);

await expect(run(`install`)).resolves.toBeTruthy();

const nmFolderCtime = xfs.statSync(npath.toPortablePath(`${path}/node_modules`)).ctime;
const depFolderCtime = xfs.statSync(npath.toPortablePath(`${path}/node_modules/no-deps`)).ctime;
console.log('nmFolderCtime', nmFolderCtime);
console.log('depFolderCtime', depFolderCtime);

await writeJson(npath.toPortablePath(`${path}/package.json`), {
private: true,
dependencies: {
[`no-deps`]: `2.0.0`,
},
});

await expect(run(`install`)).resolves.toBeTruthy();

expect(xfs.statSync(npath.toPortablePath(`${path}/node_modules`)).ctime).toEqual(nmFolderCtime);
expect(xfs.statSync(npath.toPortablePath(`${path}/node_modules/no-deps`)).ctime).toEqual(depFolderCtime);
},
),
);
});
1 change: 0 additions & 1 deletion packages/plugin-node-modules/sources/NodeModulesLinker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,6 @@ const removeDir = async (dir: PortablePath, options: {contentsOnly: boolean, inn
throw new Error(`Assertion failed: trying to remove dir that doesn't contain node_modules: ${dir}`);

try {
console.log('removeDir', dir, options);
if (!options.innerLoop) {
const stats = await xfs.lstatPromise(dir);
if (stats.isSymbolicLink()) {
Expand Down

0 comments on commit c1bd0f5

Please sign in to comment.