Skip to content

Commit

Permalink
Prevents cache removal when running an install (#7699)
Browse files Browse the repository at this point in the history
* Prevents cache removal when running an install

* Removes .bin as usual

* Update CHANGELOG.md
  • Loading branch information
arcanis committed Nov 22, 2019
1 parent a9f57e5 commit 999b2b4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Expand Up @@ -4,19 +4,22 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

## Master

- Folders like `.cache` won't be pruned from the `node_modules` after each install.

[#7699](https://github.com/yarnpkg/yarn/pull/7699) - [**Maël Nison**](https://twitter.com/arcanis)

- Correctly installs workspace child dependencies when workspace child not symlinked to root.

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

- Makes running scripts with Plug'n Play possible on node 13
- Makes running scripts with Plug'n Play possible on node 13.

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

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

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


## 1.19.1

**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.
Expand Down
10 changes: 10 additions & 0 deletions __tests__/commands/install/integration.js
Expand Up @@ -117,6 +117,16 @@ test('installing a package with a renamed file should not delete it', () =>
expect(await fs.exists(`${config.cwd}/node_modules/pkg/state.js`)).toEqual(true);
}));

test("installing a tree shouldn't remove preexisting cache directories", () =>
runInstall({}, 'cache-folder-nm', async (config, reporter): Promise<void> => {
expect(await fs.exists(`${config.cwd}/node_modules/.cache/hello.txt`)).toEqual(true);

const reInstall = new Install({}, config, reporter, await Lockfile.fromDirectory(config.cwd));
await reInstall.init();

expect(await fs.exists(`${config.cwd}/node_modules/.cache/hello.txt`)).toEqual(true);
}));

test("installing a new package should correctly update it, even if the files mtime didn't change", () =>
runInstall({}, 'mtime-same', async (config, reporter): Promise<void> => {
await misc.sleep(2000);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions __tests__/fixtures/install/cache-folder-nm/package.json
@@ -0,0 +1,5 @@
{
"dependencies": {
"feed": "0.3.0"
}
}
13 changes: 13 additions & 0 deletions __tests__/fixtures/install/cache-folder-nm/yarn.lock
@@ -0,0 +1,13 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


feed@0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/feed/-/feed-0.3.0.tgz#65bcc4c9c57fde8e277faf4afff80c2d1d90e82d"
dependencies:
xml ">= 0.0.5"

"xml@>= 0.0.5":
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
4 changes: 4 additions & 0 deletions src/package-linker.js
Expand Up @@ -346,6 +346,10 @@ export default class PackageLinker {
for (const subfile of await fs.readdir(filepath)) {
possibleExtraneous.add(path.join(filepath, subfile));
}
} else if (file[0] === '.' && file !== '.bin') {
if (!(await fs.lstat(filepath)).isDirectory()) {
possibleExtraneous.add(filepath);
}
} else {
possibleExtraneous.add(filepath);
}
Expand Down

0 comments on commit 999b2b4

Please sign in to comment.