codekingpro/portable-devtools
114k
1const { output } = require('proc-log')
2const getIdentity = require('../utils/get-identity.js')
3const BaseCommand = require('../base-cmd.js')
4
5class Whoami extends BaseCommand {
6 static description = 'Display npm username'
7 static name = 'whoami'
8 static params = ['registry']
9
10 async exec () {
11 const username = await getIdentity(this.npm, { ...this.npm.flatOptions })
12 if (this.npm.config.get('json')) {
13 output.buffer(username)
14 } else {
15 output.standard(username)
16 }
17 }
18}
19
20module.exports = Whoami
21 