np
np copied to clipboard
Incorrect file list when `.gitignore` and `.npmignore` differ
"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
- Create a
dist/folder with some contents - Create a
.gitignorethat ignores thedistfolder - Create a
.npmignorethat does not ignore thedistfolder - Add
"dist"into the"files"attrib inpackage.json - Run
npm packto generate a tar, which should contain thedistfolder - Run
np- the new file list will not containdist
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
Probably related to #615 as well.