Tip
By default npm publish
will publish all files within a working directory - excluding .gitignore
/ .npmignore
/ package-lock.json
.
This is typically fine, but often I find myself leaving un-staged files (e.g. TODO.txt
files) in a repository root and these of course get accidently taken along for the publish ride.
Helper script npm-publish-wrap.sh
will catch calls to npm publish
and:
- Ensure I'm at the root of a repository (
.git
directory) found. - Local
git clone
the current repository to a temp directory - removing any unstaged files. npm publish
the cloned repository into the registry.
I have this set as an alias
in my ~/.bash_profile
:
alias npm='/path/to/npm-publish-wrap.sh'