All files / lib whoami.js

100% Statements 14/14
100% Branches 2/2
100% Functions 3/3
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 182x 2x 2x 2x 2x   2x   2x   2x 2x 2x 2x     2x  
const npm = require('./npm.js')
const output = require('./utils/output.js')
const getIdentity = require('./utils/get-identity.js')
const usageUtil = require('./utils/usage.js')
const completion = require('./utils/completion/none.js')
 
const cmd = (args, cb) => whoami(args).then(() => cb()).catch(cb)
 
const usage = usageUtil('whoami', 'npm whoami [--registry <registry>]\n(just prints username according to given registry)')
 
const whoami = async ([spec]) => {
  const opts = npm.flatOptions
  const username = await getIdentity(opts, spec)
  output(opts.json ? JSON.stringify(username) : username)
}
 
module.exports = Object.assign(cmd, { completion, usage })