2024-04-30 23:53:22 -07:00
|
|
|
const { output } = require('proc-log')
|
2021-11-04 20:42:47 +00:00
|
|
|
const getIdentity = require('../utils/get-identity.js')
|
2024-04-30 23:53:22 -07:00
|
|
|
const BaseCommand = require('../base-cmd.js')
|
2019-01-29 14:43:00 -08:00
|
|
|
|
2021-03-11 17:54:23 -05:00
|
|
|
class Whoami extends BaseCommand {
|
2021-11-18 20:58:02 +00:00
|
|
|
static description = 'Display npm username'
|
|
|
|
static name = 'whoami'
|
|
|
|
static params = ['registry']
|
2014-09-24 14:41:07 -07:00
|
|
|
|
2024-04-30 23:53:22 -07:00
|
|
|
async exec () {
|
2022-02-24 21:41:49 +00:00
|
|
|
const username = await getIdentity(this.npm, { ...this.npm.flatOptions })
|
2024-05-30 04:21:05 -07:00
|
|
|
if (this.npm.config.get('json')) {
|
|
|
|
output.buffer(username)
|
|
|
|
} else {
|
|
|
|
output.standard(username)
|
|
|
|
}
|
2021-03-04 17:40:28 -05:00
|
|
|
}
|
|
|
|
}
|
2024-04-30 23:53:22 -07:00
|
|
|
|
2021-03-04 17:40:28 -05:00
|
|
|
module.exports = Whoami
|