feat(inspect): add --rule and --plugin options for inspect command

This commit is contained in:
Evan You
2018-05-11 17:16:20 -04:00
parent 853662c64f
commit 82349ba254
3 changed files with 15 additions and 3 deletions
@@ -83,6 +83,8 @@ module.exports = (api, options) => {
usage: 'vue-cli-service inspect [options] [...paths]',
options: {
'--mode': 'specify env mode (default: development)',
'--rule': 'inspect a specific module rule',
'--plugin': 'inspect a specific plugin',
'--verbose': 'show full function definitions in output'
}
}, args => {
@@ -94,7 +96,11 @@ module.exports = (api, options) => {
const paths = args._
let res
if (paths.length > 1) {
if (args.rule) {
res = config.module.rules.find(r => r.__ruleName === args.rule)
} else if (args.plugin) {
res = config.plugins.find(p => p.__pluginName === args.plugin)
} else if (paths.length > 1) {
res = {}
paths.forEach(path => {
res[path] = get(config, path)
@@ -106,7 +112,7 @@ module.exports = (api, options) => {
}
const pluginRE = /(?:function|class) (\w+Plugin)/
console.log(stringify(res, (value, indent, stringify) => {
const output = stringify(res, (value, indent, stringify) => {
// shorten long functions
if (
!args.verbose &&
@@ -151,7 +157,9 @@ module.exports = (api, options) => {
}
return stringify(value)
}, 2))
}, 2)
console.log(output)
})
}
+2
View File
@@ -68,6 +68,8 @@ program
program
.command('inspect [paths...]')
.option('--mode <mode>')
.option('--rule <ruleName>', 'inspect a specific module rule')
.option('--plugin <pluginName>', 'inspect a specific plugin')
.option('-v --verbose', 'Show full function definitions in output')
.description('inspect the webpack config in a project with vue-cli-service')
.action((paths, cmd) => {
+2
View File
@@ -19,6 +19,8 @@ module.exports = function inspect (paths, args) {
binPath,
'inspect',
...(args.mode ? ['--mode', args.mode] : []),
...(args.rule ? ['--rule', args.rule] : []),
...(args.plugin ? ['--plugin', args.plugin] : []),
...(args.verbose ? ['--verbose'] : []),
...paths
], { cwd, stdio: 'inherit' })