Skip to content

Commit 1b00b2f

Browse files
committed
Replace CLI args parser MRI with built in parseArgs util
1 parent e557eb1 commit 1b00b2f

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

bin/npm-dist-tag

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env node
22

3-
const mri = require('mri')
43
const npmDistTag = require('../')
4+
const { parseArgs } = require('node:util')
55

66
const help = `
77
Usage: npm-dist-tag [options]
@@ -14,21 +14,25 @@ Options:
1414

1515
const run = async () => {
1616
try {
17-
const args = process.argv.slice(2)
18-
19-
const options = mri(args, {
20-
alias: {
21-
p: 'package',
22-
v: 'version',
23-
h: 'help'
17+
const { values } = parseArgs({
18+
options: {
19+
package: {
20+
type: 'string',
21+
short: 'p',
22+
},
23+
version: {
24+
type: 'string',
25+
short: 'v',
26+
},
27+
help: {
28+
type: 'boolean'
29+
},
2430
},
25-
unknown: (option) => {
26-
const message = `Unknown option "${option}"`
27-
throw Error([message, help].join('\n'))
28-
}
2931
})
3032

31-
const result = options.help ? help : await npmDistTag(options)
33+
console.log(values)
34+
35+
const result = values.help ? help : await npmDistTag(values)
3236

3337
console.log(result)
3438
process.exit(0)

0 commit comments

Comments
 (0)