blob: 8e1c1d0523ae3170a01aa72e3dc6747220f5885a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
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 })
|