-
Notifications
You must be signed in to change notification settings - Fork 0
/
whoami.js
31 lines (26 loc) · 804 Bytes
/
whoami.js
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