Open danschumann opened 10 years ago
If npm-shrinkwrap
doesn't write npm-shrinkwrap.json
then it will have errored out.
I don't know why it doesn't work :(
I'd like to try this, did you remember to run git add
in your hook?
The following suffices:
#!/bin/sh
set -e
if ! git diff --cached --quiet -- package.json; then
npm shrinkwrap # or npm run ... to taste
git add npm-shrinkwrap.json
fi
Tested in a trivial foo repo, it:
Yeah I just did the same, works fine! If you leave out the package.json
check, though, it will detect modules which are not saved in your package.json.
@jcorbin thanks for that snippet!
I used it to make this drop-in hook code https://github.com/turadg/npm-shrinkwrap-git-hooks
Hey I put
npm shrinkwrap
into a pre-commit git hook, but either git does its check too soon, or shrinkwrap writes it too late, because that commit doesn't have a changed shrinkwrap.I'd like to automatically shrinkwrap before a commit and have the changed shrinkwrap file go into that same commit. Is this possible or do I need to write a bash script?