np icon indicating copy to clipboard operation
np copied to clipboard

Incorrect file list when `.gitignore` and `.npmignore` differ

Open groenroos opened this issue 2 years ago • 1 comments

"The following new files will be published the first time" list of files does not take into account .npmignore's precedence over .gitignore when a file is excluded in the latter but not the former.

Description

I want a dist/ folder to be included in the package, but excluded from git.

So I have a .gitignore file that ignores dist; an .npmignore that doesn't; and a "files" parameter that explicitly wants to include it.

.gitignore
node_modules/
npm-debug.log
env
.DS_Store
dist
.npmignore
node_modules/
npm-debug.log
env
.DS_Store
package.json
{
    ...
    "files": [
        "dist",
        "index.js"
    ]
}

However, the dist folder and all its contents are excluded from the "following new files will be published the first time" list in the UI. Seems like neither removing .npmignore nor "files" changes this - only removing dist from .gitignore (which is undesirable) displays the correct list of files.

Based on the above setup, npm pack creates a tar that does include the dist folder, so it appears the file list in the UI is incorrect (or I'm missing something obvious)

Steps to reproduce

  1. Create a dist/ folder with some contents
  2. Create a .gitignore that ignores the dist folder
  3. Create a .npmignore that does not ignore the dist folder
  4. Add "dist" into the "files" attrib in package.json
  5. Run npm pack to generate a tar, which should contain the dist folder
  6. Run np - the new file list will not contain dist

Expected behavior

The UI displaying the list of files should include the contents of the dist folder, to match the tar generated by npm pack under these circumstances.

Environment

np - 7.5.0 Node.js - 14.18.1 npm - 6.4.15 Git - 2.31.1 OS - macOS 11.6

groenroos avatar Oct 30 '21 21:10 groenroos

Probably related to #615 as well.

rootwork avatar Nov 15 '21 21:11 rootwork