Skip to content

Commit 0936cee

Browse files
alfaprojectvsavkin
authored andcommitted
chore(npm): clean up clean-shrinkwrap script
1 parent e0ad413 commit 0936cee

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

tools/npm/clean-shrinkwrap.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,30 @@
1414
* See: https://github.com/npm/npm/issues/3581
1515
*/
1616

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');
2119

2220

23-
function cleanModule(moduleRecord, name) {
21+
function cleanModule(moduleRecord) {
2422
// keep `resolve` properties for git dependencies, delete otherwise
2523
delete moduleRecord.from;
2624
if (!(moduleRecord.resolved && moduleRecord.resolved.match(/^git(\+[a-z]+)?:\/\//))) {
2725
delete moduleRecord.resolved;
2826
}
2927

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+
}
3132
}
3233

3334

3435
// console.log('Reading npm-shrinkwrap.json');
35-
var shrinkwrap = require('../../npm-shrinkwrap.json');
36+
const shrinkwrap = require('../../npm-shrinkwrap.json');
3637

3738
// console.log('Cleaning shrinkwrap object');
38-
cleanModule(shrinkwrap, shrinkwrap.name);
39+
cleanModule(shrinkwrap);
3940

40-
var cleanShrinkwrapPath = path.join(__dirname, '..', '..', 'npm-shrinkwrap.clean.json');
41+
const cleanShrinkwrapPath = path.join(__dirname, '..', '..', 'npm-shrinkwrap.clean.json');
4142
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

Comments
 (0)