Skip to content

Commit 0dbbffa

Browse files
committed
fix: simplify argument handling
- remove unneeded overhead in arg handling Signed-off-by: Michael Dawson <[email protected]>
1 parent 518a300 commit 0dbbffa

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

lib/cli/commands/show.js

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ const support = require('../../../index.js')
33

44
// print out the information for a module and its
55
// children
6-
function printModule (module, depth) {
6+
function printModule (module, depth, argv) {
77
const pkg = module.package
88
const moduleInfo = `${pkg.name}(${pkg.version})`
99

10-
const supportInfo = support.getSupportData(pkg, module.path, preferCanonical, basePathOverride)
10+
const supportInfo = support.getSupportData(pkg, module.path, argv.canonical, argv['base-path'])
1111
if (supportInfo.resolved) {
1212
console.log(`${' '.repeat(2 * (depth + 1))}${moduleInfo} - ${supportInfo.contents}`)
1313
} else {
@@ -20,8 +20,6 @@ function printModule (module, depth) {
2020
})
2121
};
2222

23-
let preferCanonical = false
24-
let basePathOverride
2523
module.exports = function (opts) {
2624
return {
2725
command: 'show',
@@ -30,18 +28,10 @@ module.exports = function (opts) {
3028
return yargs
3129
},
3230
handler: function (argv) {
33-
preferCanonical = false
34-
if (argv.canonical) {
35-
preferCanonical = true
36-
}
37-
basePathOverride = undefined
38-
if (argv['base-path']) {
39-
basePathOverride = argv['base-path']
40-
}
4131
const Arborist = require('@npmcli/arborist')
4232
const arb = new Arborist()
4333
arb.loadActual().then(root => {
44-
printModule(root, 0)
34+
printModule(root, 0, argv)
4535
})
4636
}
4737
}

0 commit comments

Comments
 (0)