Skip to content

Commit 98d51d8

Browse files
authored
Prevents cache removal when running an install (#7699)
* Prevents cache removal when running an install * Removes .bin as usual * Update CHANGELOG.md
1 parent c43f66d commit 98d51d8

File tree

6 files changed

+38
-2
lines changed

6 files changed

+38
-2
lines changed

CHANGELOG.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa
44

55
## Master
66

7+
- Folders like `.cache` won't be pruned from the `node_modules` after each install.
8+
9+
[#7699](https://github.com/yarnpkg/yarn/pull/7699) - [**Maël Nison**](https://twitter.com/arcanis)
10+
711
- Correctly installs workspace child dependencies when workspace child not symlinked to root.
812

913
[#7289](https://github.com/yarnpkg/yarn/pull/7289) - [**Daniel Tschinder**](https://github.com/danez)
1014

11-
- Makes running scripts with Plug'n Play possible on node 13
15+
- Makes running scripts with Plug'n Play possible on node 13.
1216

1317
[#7650](https://github.com/yarnpkg/yarn/pull/7650) - [**Sander Verweij**](https://github.com/sverweij)
1418

1519
- Change run command to check cwd/node_modules/.bin for commands. Fixes run in workspaces.
1620

1721
[#7151](https://github.com/yarnpkg/yarn/pull/7151) - [**Jeff Valore**](https://twitter.com/codingwithspike)
1822

19-
2023
## 1.19.1
2124

2225
**Important:** This release contains a cache bump. It will cause the very first install following the upgrade to take slightly more time, especially if you don't use the [Offline Mirror](https://yarnpkg.com/blog/2016/11/24/offline-mirror/) feature. After that everything will be back to normal.

__tests__/commands/install/integration.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,16 @@ test('installing a package with a renamed file should not delete it', () =>
117117
expect(await fs.exists(`${config.cwd}/node_modules/pkg/state.js`)).toEqual(true);
118118
}));
119119

120+
test("installing a tree shouldn't remove preexisting cache directories", () =>
121+
runInstall({}, 'cache-folder-nm', async (config, reporter): Promise<void> => {
122+
expect(await fs.exists(`${config.cwd}/node_modules/.cache/hello.txt`)).toEqual(true);
123+
124+
const reInstall = new Install({}, config, reporter, await Lockfile.fromDirectory(config.cwd));
125+
await reInstall.init();
126+
127+
expect(await fs.exists(`${config.cwd}/node_modules/.cache/hello.txt`)).toEqual(true);
128+
}));
129+
120130
test("installing a new package should correctly update it, even if the files mtime didn't change", () =>
121131
runInstall({}, 'mtime-same', async (config, reporter): Promise<void> => {
122132
await misc.sleep(2000);

__tests__/fixtures/install/cache-folder-nm/node_modules/.cache/hello.txt

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"dependencies": {
3+
"feed": "0.3.0"
4+
}
5+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
6+
version "0.3.0"
7+
resolved "https://registry.yarnpkg.com/feed/-/feed-0.3.0.tgz#65bcc4c9c57fde8e277faf4afff80c2d1d90e82d"
8+
dependencies:
9+
xml ">= 0.0.5"
10+
11+
"xml@>= 0.0.5":
12+
version "1.0.1"
13+
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"

src/package-linker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,10 @@ export default class PackageLinker {
346346
for (const subfile of await fs.readdir(filepath)) {
347347
possibleExtraneous.add(path.join(filepath, subfile));
348348
}
349+
} else if (file[0] === '.' && file !== '.bin') {
350+
if (!(await fs.lstat(filepath)).isDirectory()) {
351+
possibleExtraneous.add(filepath);
352+
}
349353
} else {
350354
possibleExtraneous.add(filepath);
351355
}

0 commit comments

Comments
 (0)