Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Files under directories already added to files of package.json cannot be excluded by adding them to files (like !some_directory). #2649

Closed
korosuke613 opened this issue Feb 8, 2021 · 2 comments

Comments

@korosuke613
Copy link

korosuke613 commented Feb 8, 2021

Current Behavior

Files under directories already added to files of package.json cannot be excluded by adding them to files (like !some_directory). Up to npm 6.14.11 it was possible to exclude, but from npm 7.5.2 it is no longer possible.

  • package.json, src/index.js, src/__tests__/indexTest.js are added to the npm package.
❯ npm pack --dry-run      
...
npm notice === Tarball Contents === 
npm notice 97B package.json              
npm notice 0B  src/__tests__/indexTest.js
npm notice 21B src/index.js              
npm notice === Tarball Details === 
...
npm notice total files:   3                                       
...

Expected Behavior

  • package.json, src/index.js are added to the npm package. (use npm 6.14.11)
❯ npm pack --dry-run
...
npm notice === Tarball Contents === 
npm notice 21B src/index.js
npm notice 97B package.json
npm notice === Tarball Details === 
...
npm notice total files:   2                                       
...

Steps to Reproduce

  1. Create a package.json
{
  "name": "some-package",
  "files": [
    "src",
    "!__tests__"
  ],
  "version": "0.0.0"
}
  1. Create the following file structure:
  .
  └── src
     ├── index.js
     └── __tests__
        └── indexTest.js
  1. run npm pack --dry-run

Other

By using wildcards, you can exclude them in both npm v6/v7. (ex. !__tests__ -> !**/__tests__)

Environment:

  • OS: macOS 11.1
  • Node: 12.18.2
  • npm: 7.5.2
@ljharb
Copy link
Contributor

ljharb commented Feb 8, 2021

Seems like a duplicate of #2441?

@korosuke613
Copy link
Author

Oh, I'm sorry. As you say, this issue was a duplicate of the linked issue. Thank you.

@ljharb ljharb closed this as completed Feb 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants