@npmcli/arborist 2.7.0 → 2.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/dedupe.js ADDED
@@ -0,0 +1,46 @@
1
+ const Arborist = require('../')
2
+
3
+ const options = require('./lib/options.js')
4
+ const print = require('./lib/print-tree.js')
5
+ require('./lib/logging.js')
6
+ require('./lib/timers.js')
7
+
8
+ const printDiff = diff => {
9
+ const {depth} = require('treeverse')
10
+ depth({
11
+ tree: diff,
12
+ visit: d => {
13
+ if (d.location === '')
14
+ return
15
+ switch (d.action) {
16
+ case 'REMOVE':
17
+ console.error('REMOVE', d.actual.location)
18
+ break
19
+ case 'ADD':
20
+ console.error('ADD', d.ideal.location, d.ideal.resolved)
21
+ break
22
+ case 'CHANGE':
23
+ console.error('CHANGE', d.actual.location, {
24
+ from: d.actual.resolved,
25
+ to: d.ideal.resolved,
26
+ })
27
+ break
28
+ }
29
+ },
30
+ getChildren: d => d.children,
31
+ })
32
+ }
33
+
34
+ const start = process.hrtime()
35
+ process.emit('time', 'install')
36
+ const arb = new Arborist(options)
37
+ arb.dedupe(options).then(tree => {
38
+ process.emit('timeEnd', 'install')
39
+ const end = process.hrtime(start)
40
+ print(tree)
41
+ if (options.dryRun)
42
+ printDiff(arb.diff)
43
+ console.error(`resolved ${tree.inventory.size} deps in ${end[0] + end[1] / 1e9}s`)
44
+ if (tree.meta && options.save)
45
+ tree.meta.save()
46
+ }).catch(er => console.error(require('util').inspect(er, { depth: Infinity })))