1const getIdentity = require('../utils/get-identity.js') 2 3const BaseCommand = require('../base-command.js') 4class Whoami extends BaseCommand { 5 static description = 'Display npm username' 6 static name = 'whoami' 7 static params = ['registry'] 8 9 async exec (args) { 10 const username = await getIdentity(this.npm, { ...this.npm.flatOptions }) 11 this.npm.output( 12 this.npm.config.get('json') ? JSON.stringify(username) : username 13 ) 14 } 15} 16module.exports = Whoami 17