sfcode
An Online Competing and Development Environment
|
Get a list of the files to add from a folder into an npm package
These can be handed to tar like so to make an npm package tarball:
This uses the following rules:
package.json
file is found, and it has a files
list, then ignore everything that isn't in files
. Always include the readme, license, notice, changes, changelog, and history files, if they exist, and the package.json file itself.package.json
file (or it has no files
list), and there is a .npmignore
file, then ignore all the files in the .npmignore
file.package.json
with a files
list, and there's no .npmignore
file, but there is a .gitignore
file, then ignore all the files in the .gitignore
file.node_modules
is ignored, unless it's a bundled dependency. If it IS a bundled dependency, and it's a symbolic link, then the target of the link is included, not the symlink itself.Unless they're explicitly included (by being in a files
list, or a !negated
rule in a relevant .npmignore
or .gitignore
), always ignore certain common cruft files:
.*.swp
, ._*
and .*.orig
files.npmrc
files (these may contain private configs)node_modules/.bin
folder/build/config.gypi
and .lock-wscript
.DS_Store
files because wtf are those evennpm-debug.log
files at the root of a projectYou can explicitly re-include any of these with a files
list in package.json
or a negated ignore file rule.
Same API as ignore-walk, just hard-coded file list and rule sets.
The Walker
and WalkerSync
classes take a bundled
argument, which is a list of package names to include from node_modules. When calling the top-level packlist()
and packlist.sync()
functions, this module calls into npm-bundled
directly.