Skip to content

Commit 4b77475

Browse files
committed
chore(cli): upgrade commander to v8
1 parent e5d2821 commit 4b77475

File tree

3 files changed

+22
-33
lines changed

3 files changed

+22
-33
lines changed

package-lock.json

+8-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"dependencies": {
7575
"async": "3.2.2",
7676
"chalk": "^4.1.2",
77-
"commander": "5.1.0",
77+
"commander": "^8.3.0",
7878
"glob": "^7.2.0",
7979
"node-fetch": "^2.6.2",
8080
"parse-glob": "3.0.4",

src/cli/htmlhint.ts

+13-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { queue as asyncQueue, series as asyncSeries } from 'async'
44
import * as chalk from 'chalk'
5-
import * as program from 'commander'
5+
import { Command } from 'commander'
66
import { existsSync, readFileSync, statSync } from 'fs'
77
import * as glob from 'glob'
88
import { IGlob } from 'glob'
@@ -28,6 +28,8 @@ function map(val: string) {
2828
return objMap
2929
}
3030

31+
const program = new Command()
32+
3133
program.on('--help', () => {
3234
console.log(' Examples:')
3335
console.log('')
@@ -76,7 +78,9 @@ program
7678
.option('--warn', 'Warn only, exit with 0')
7779
.parse(process.argv)
7880

79-
if (program.list) {
81+
const cliOptions = program.opts()
82+
83+
if (cliOptions.list) {
8084
listRules()
8185
process.exit(0)
8286
}
@@ -88,19 +92,19 @@ if (arrTargets.length === 0) {
8892

8993
// init formatter
9094
formatter.init(HTMLHint, {
91-
nocolor: program.nocolor,
95+
nocolor: cliOptions.nocolor,
9296
})
9397

94-
const format = program.format || 'default'
98+
const format = cliOptions.format || 'default'
9599
if (format) {
96100
formatter.setFormat(format)
97101
}
98102

99103
hintTargets(arrTargets, {
100-
rulesdir: program.rulesdir,
101-
ruleset: program.rules,
104+
rulesdir: cliOptions.rulesdir,
105+
ruleset: cliOptions.rules,
102106
formatter: formatter,
103-
ignore: program.ignore,
107+
ignore: cliOptions.ignore,
104108
})
105109

106110
// list all rules
@@ -170,7 +174,7 @@ function hintTargets(
170174
allHintCount: allHintCount,
171175
time: spendTime,
172176
})
173-
process.exit(!program.warn && allHintCount > 0 ? 1 : 0)
177+
process.exit(!cliOptions.warn && allHintCount > 0 ? 1 : 0)
174178
})
175179
}
176180

@@ -244,7 +248,7 @@ function hintAllFiles(
244248
// init ruleset
245249
let ruleset = options.ruleset
246250
if (ruleset === undefined) {
247-
ruleset = getConfig(program.config, globInfo.base, formatter)
251+
ruleset = getConfig(cliOptions.config, globInfo.base, formatter)
248252
}
249253

250254
// hint queue

0 commit comments

Comments
 (0)