gulp-shrinkwrap
Run
npm shrinkwrap
from a gulp task against a givenpackage.json
file. Also allow lockingpackage.json
dependencies to specific versions.
Install
npm install gulp-shrinkwrap --save-dev
Usage
See the API documentation for more details.
shrinkwrap
Given a gulpfile.js
var gulp = shrinkwrap = ; gulp; gulp;
When running
$ gulp shrinkwrap
Then a npm-shrinkwrap.json
file will generated at the
destination of your choice.
Important Notes
- Without the call to
gulp.dest
, anpm-shrinkwrap.json
file will not be created. - By default,
npm shrinkwrap
will be executed at the path where the suppliedpackage.json
file resides. If you want it run in a different context you must supply theprefix
option.
shrinkwrap.lock
Given a gulpfile.js
var gulp = shrinkwrap = ; gulp;
And a package.json
When running
$ gulp shrinkwrap
Then the package.json
file will be modified to be this
All together
// gulpfile.jsvar gulp = shrinkwrap = ; gulp;
Note: if you try to just drop the above code into your project, the call will likely fail. This is because, if you use
wildcards, those will be locked to a specific version but the actual versions installed under node_modules
will
likely be newer. This will cause a failure during npm shrinkwrap
. To get around this, lock your package.json
first,
re-install all dependencies and then shrinkwrap.
Always keep your shrinkwrap up to date
You'll want to update your npm-shrinkwrap.json
every time you install a new dependency.
An easy way to do this automatically is via a pre-commit
git hook
#!/bin/sh # # Run gulp shrinkwrap on every commit so that we always have the most recent # dependencies checked in. npm prune > /dev/nullerror=$(gulp shrinkwrap) # If modified adds file(s) and includes them in commit. git add package.jsongit add npm-shrinkwrap.json