blob: 180eb331759eff8069e85bdbc554ea2f139ff75c (
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 name () {
return 'whoami'
}
/* istanbul ignore next - see test/lib/load-all-commands.js */
static get description () {
return 'prints username according to given registry'
}
/* istanbul ignore next - see test/lib/load-all-commands.js */
static get usage () {
return ['[--registry <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
|