|
14 | 14 | * See: https://github.com/npm/npm/issues/3581 |
15 | 15 | */ |
16 | 16 |
|
17 | | -var _ = require('lodash'); |
18 | | -var sorted = require('sorted-object'); |
19 | | -var fs = require('fs'); |
20 | | -var path = require('path'); |
| 17 | +const fs = require('fs'); |
| 18 | +const path = require('path'); |
21 | 19 |
|
22 | 20 |
|
23 | | -function cleanModule(moduleRecord, name) { |
| 21 | +function cleanModule(moduleRecord) { |
24 | 22 | // keep `resolve` properties for git dependencies, delete otherwise |
25 | 23 | delete moduleRecord.from; |
26 | 24 | if (!(moduleRecord.resolved && moduleRecord.resolved.match(/^git(\+[a-z]+)?:\/\//))) { |
27 | 25 | delete moduleRecord.resolved; |
28 | 26 | } |
29 | 27 |
|
30 | | - _.forEach(moduleRecord.dependencies, function(mod, name) { cleanModule(mod, name); }); |
| 28 | + if (moduleRecord.dependencies) { |
| 29 | + Object.keys(moduleRecord.dependencies) |
| 30 | + .forEach((name) => cleanModule(moduleRecord.dependencies[name])); |
| 31 | + } |
31 | 32 | } |
32 | 33 |
|
33 | 34 |
|
34 | 35 | // console.log('Reading npm-shrinkwrap.json'); |
35 | | -var shrinkwrap = require('../../npm-shrinkwrap.json'); |
| 36 | +const shrinkwrap = require('../../npm-shrinkwrap.json'); |
36 | 37 |
|
37 | 38 | // console.log('Cleaning shrinkwrap object'); |
38 | | -cleanModule(shrinkwrap, shrinkwrap.name); |
| 39 | +cleanModule(shrinkwrap); |
39 | 40 |
|
40 | | -var cleanShrinkwrapPath = path.join(__dirname, '..', '..', 'npm-shrinkwrap.clean.json'); |
| 41 | +const cleanShrinkwrapPath = path.join(__dirname, '..', '..', 'npm-shrinkwrap.clean.json'); |
41 | 42 | console.log('writing npm-shrinkwrap.clean.json'); |
42 | | -fs.writeFileSync(cleanShrinkwrapPath, JSON.stringify(sorted(shrinkwrap), null, 2) + '\n'); |
| 43 | +fs.writeFileSync(cleanShrinkwrapPath, JSON.stringify(shrinkwrap, null, 2) + '\n'); |
0 commit comments