whoami.js 527 B

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