`yarn pack` includes unexpected files with a negative expression in `files` of package.json
Bug description
Command
yarn pack
What is the current behavior?
When files of package.json includes a negative expression, yarn pack includes unexpected files (I guess the whole directory).
What is the expected behavior?
It should include only what it's supposed to include. The output is different from npm pack.
Steps to Reproduce
git clone [email protected]:eunjae-lee/yarn-pack-issue.git- Run
touch .env && yarn pack - You will see
this-file-should-not-be-packed.jsand.envare included in the tgz file.
What is worse is that .env is in .gitignore. (It's the same even if it's also included in .npmignore.)
- If you remove the line 8 of package.json which is
"!**/__tests__/**", - then run again
yarn pack - This time, it doesn't include
this-file-should-not-be-packed.jsor.env.
Environment
- Node Version:
12.18.0 - Yarn v1 Version:
1.16.0and1.22.5 - OS and version: macOS 10.15.3
Related Issues
- https://github.com/yarnpkg/yarn/issues/5779
- https://github.com/yarnpkg/yarn/issues/7391
It seems yarn is matching all files against all matchers, but only files that match on positive matchers should be compared against negative matchers and then omitted.
is there a way to have the files property handled exactly the same way than on npm?
This is completely broken, caught me when moving from npm to yarn.