cli_command_misc_global-dir.js
import epilog from '../../lib/epilog.js'
import { dropRight } from 'lodash-es'
import getGlobalPath from 'get-global-path'
import resolvePath from 'aneka/src/resolve-path.js'
import { __ } from '../../lib/translate.js'
/**
* Command definition object for showing the npm global directory.
*
* @memberof module:CLI/Command/Misc
* @type {TCommand}
*/
const globalDir = {
command: __('%s', 'gdir'),
describe: __('Show npm global directory'),
builder (yargs) {
yargs.epilog(epilog)
},
async handler (argv) {
const npmPath = getGlobalPath('npm')
const dir = dropRight(resolvePath(npmPath).split('/'), 1).join('/')
console.log(dir)
}
}
export default globalDir