Skip to content

Commit fd1c0d5

Browse files
committed
feat(inspect): add --rules and --plugins options for inspect command
1 parent 82349ba commit fd1c0d5

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

packages/@vue/cli-service/lib/commands/inspect.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,10 @@ module.exports = (api, options) => {
8383
usage: 'vue-cli-service inspect [options] [...paths]',
8484
options: {
8585
'--mode': 'specify env mode (default: development)',
86-
'--rule': 'inspect a specific module rule',
87-
'--plugin': 'inspect a specific plugin',
86+
'--rule <ruleName>': 'inspect a specific module rule',
87+
'--plugin <pluginName>': 'inspect a specific plugin',
88+
'--rules': 'list all module rule names',
89+
'--plugins': 'list all plugin names',
8890
'--verbose': 'show full function definitions in output'
8991
}
9092
}, args => {
@@ -100,6 +102,10 @@ module.exports = (api, options) => {
100102
res = config.module.rules.find(r => r.__ruleName === args.rule)
101103
} else if (args.plugin) {
102104
res = config.plugins.find(p => p.__pluginName === args.plugin)
105+
} else if (args.rules) {
106+
res = config.module.rules.map(r => r.__ruleName)
107+
} else if (args.plugins) {
108+
res = config.plugins.map(p => p.__pluginName)
103109
} else if (paths.length > 1) {
104110
res = {}
105111
paths.forEach(path => {

packages/@vue/cli/bin/vue.js

+2
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ program
7070
.option('--mode <mode>')
7171
.option('--rule <ruleName>', 'inspect a specific module rule')
7272
.option('--plugin <pluginName>', 'inspect a specific plugin')
73+
.option('--rules', 'list all module rule names')
74+
.option('--plugins', 'list all plugin names')
7375
.option('-v --verbose', 'Show full function definitions in output')
7476
.description('inspect the webpack config in a project with vue-cli-service')
7577
.action((paths, cmd) => {

packages/@vue/cli/lib/inspect.js

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ module.exports = function inspect (paths, args) {
2121
...(args.mode ? ['--mode', args.mode] : []),
2222
...(args.rule ? ['--rule', args.rule] : []),
2323
...(args.plugin ? ['--plugin', args.plugin] : []),
24+
...(args.rules ? ['--rules'] : []),
25+
...(args.plugins ? ['--plugins'] : []),
2426
...(args.verbose ? ['--verbose'] : []),
2527
...paths
2628
], { cwd, stdio: 'inherit' })

0 commit comments

Comments
 (0)