diff options
| author | Peter Bacon Darwin | 2014-03-13 18:30:17 +0000 |
|---|---|---|
| committer | Igor Minar | 2014-03-14 23:01:54 -0700 |
| commit | dd3587a8c1977a1453063f42bb0dc511e67487a4 (patch) | |
| tree | bc8faf3022986ec567a67bf68e5cb8a4dd0121e8 /scripts | |
| parent | e5dd832b20d92970837c9f9e75c19a3ce818d065 (diff) | |
| download | angular.js-dd3587a8c1977a1453063f42bb0dc511e67487a4.tar.bz2 | |
chore(clean-shrinkwrap): add a utility to clean up the shrinkwrap file
This is to deal with https://github.com/npm/npm/issues/3581
See the previous commit for more info.
Closes #6672
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/clean-shrinkwrap.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/scripts/clean-shrinkwrap.js b/scripts/clean-shrinkwrap.js new file mode 100755 index 00000000..f3d6ebe5 --- /dev/null +++ b/scripts/clean-shrinkwrap.js @@ -0,0 +1,45 @@ +#!/usr/bin/env node + +/** + * this script is just a temporary solution to deal with the issue of npm outputting the npm + * shrinkwrap file in an unstable manner. + * + * See: https://github.com/npm/npm/issues/3581 + */ + +var _ = require('lodash'); +var sorted = require('sorted-object'); +var fs = require('fs'); + + +function cleanModule(module, name) { + + // keep `from` and `resolve` properties for git dependencies, delete otherwise + if (!(module.resolved && module.resolved.match(/^git:\/\//))) { + delete module.from; + delete module.resolved; + } + + if (name === 'chokidar') { + if (module.version === '0.8.1') { + delete module.dependencies; + } else { + throw new Error("Unfamiliar chokidar version (v" + module.version + + ") , please check status of https://github.com/paulmillr/chokidar/pull/106"); + } + } + + _.forEach(module.dependencies, function(mod, name) { + cleanModule(mod, name); + }); +} + + +console.log('Reading npm-shrinkwrap.json'); +var shrinkwrap = require('./../npm-shrinkwrap.json'); + +console.log('Cleaning shrinkwrap object'); +cleanModule(shrinkwrap, shrinkwrap.name); + +console.log('Writing cleaned npm-shrinkwrap.json'); +fs.writeFileSync('./npm-shrinkwrap.json', JSON.stringify(sorted(shrinkwrap), null, 2) + "\n"); |
