How can package files (these to be published) be listed to debug records in .npmignore?
I'm looking for something like equivalent of git ls-files for .gitignore.
The only way I have found so far is to pack the package and then list the archive which I find a bit clumsy:
npm pack
tar -tzf <package-id>.tgz
As Mike 'Pomax' Kamermans mentioned in comment the fact that
.npmignoreand.gitignoreuse the same syntax can be leveraged:The command above lists exactly files that are not npm-ignored according to
.npmignorefile. (On top of that npm automatically ignores some other entries likenode_modules.)Git
ls-filescommand generally lists combinations of files in working directory and index.-coption says show cached files-oshow 'other', i.e. untracked files--exclude-per-directory=.npmignoreuse.npmignoreas name of files of ignore entriesEDIT: Since the approach above has bunch of exceptions - files that will never or always included regardless of content of the
.npmignore- I find it unreliable. Following command is heavyweight but reliable:It packages the project, lists package files and at the end removes created package.