blob: 82c4520d9e883083f20f671d0fb650276f39b35c (
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
|
const getIdentity = require('./utils/get-identity.js')
const BaseCommand = require('./base-command.js')
class Whoami extends BaseCommand {
/* istanbul ignore next - see test/lib/load-all-commands.js */
static get description () {
return 'Display npm username'
}
/* istanbul ignore next - see test/lib/load-all-commands.js */
static get name () {
return 'whoami'
}
/* istanbul ignore next - see test/lib/load-all-commands.js */
static get params () {
return ['registry']
}
exec (args, cb) {
this.whoami(args).then(() => cb()).catch(cb)
}
async whoami (args) {
const username = await getIdentity(this.npm, this.npm.flatOptions)
this.npm.output(
this.npm.config.get('json') ? JSON.stringify(username) : username
)
}
}
module.exports = Whoami
|