blob: aa8318bfdf8cfb29d279e7f968e68b9624422c74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
'use strict'
const Arborist = require('@npmcli/arborist')
const npm = require('./npm.js')
const usage = require('./utils/usage.js')
const output = require('./utils/output.js')
cmd.usage = usage(
'update',
'npm update [-g] [<pkg>...]'
)
module.exports = cmd
function cmd(args, cb) {
update(args, cb)
.then(() => cb())
.catch(cb)
}
async function update (args) {
const update = args.length === 0 ? true : args
const where = npm.flatOptions.global
? globalTop
: npm.prefix
const arb = new Arborist({
...npm.flatOptions,
path: where
})
const start = Date.now()
await arb.reify({ update })
const stop = Date.now()
const time = (stop - start) / 1000
const pkgCount = arb.diff.children.length
const added = `updated ${pkgCount}`
output(`${added} packages in ${time}s`)
}
|