Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f1f5750

Browse files
committedApr 25, 2018
feat(inspect): add a -v/--verbose flag to inspect command to output full functions (vuejs#1157)
1 parent fe0c569 commit f1f5750

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed
 

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

+11-8
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ module.exports = (api, options) => {
33
description: 'inspect internal webpack config',
44
usage: 'vue-cli-service inspect [options] [...paths]',
55
options: {
6-
'--mode': 'specify env mode (default: development)'
6+
'--mode': 'specify env mode (default: development)',
7+
'--verbose': 'show full function definitions in output'
78
}
89
}, args => {
910
api.setMode(args.mode || 'development')
@@ -27,13 +28,15 @@ module.exports = (api, options) => {
2728

2829
const pluginRE = /(?:function|class) (\w+Plugin)/
2930
console.log(stringify(res, (value, indent, stringify) => {
30-
if (typeof value === 'function' && value.toString().length > 100) {
31-
return `function () { /* omitted long function */ }`
32-
}
33-
if (value && typeof value.constructor === 'function') {
34-
const match = value.constructor.toString().match(pluginRE)
35-
if (match) {
36-
return `/* ${match[1]} */ ` + stringify(value)
31+
if (!args.verbose) {
32+
if (typeof value === 'function' && value.toString().length > 100) {
33+
return `function () { /* omitted long function */ }`
34+
}
35+
if (value && typeof value.constructor === 'function') {
36+
const match = value.constructor.toString().match(pluginRE)
37+
if (match) {
38+
return `/* ${match[1]} */ ` + stringify(value)
39+
}
3740
}
3841
}
3942
return stringify(value)

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ program
6666
program
6767
.command('inspect [paths...]')
6868
.option('--mode <mode>')
69+
.option('-v --verbose', 'Show full function definitions in output')
6970
.description('inspect the webpack config in a project with vue-cli-service')
7071
.action((paths, cmd) => {
71-
require('../lib/inspect')(paths, cmd.mode)
72+
require('../lib/inspect')(paths, cleanArgs(cmd))
7273
})
7374

7475
program

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const path = require('path')
33
const execa = require('execa')
44
const resolve = require('resolve')
55

6-
module.exports = function inspect (paths, mode) {
6+
module.exports = function inspect (paths, args) {
77
const cwd = process.cwd()
88
let servicePath
99
try {
@@ -18,7 +18,8 @@ module.exports = function inspect (paths, mode) {
1818
execa('node', [
1919
binPath,
2020
'inspect',
21-
...(mode ? ['--mode', mode] : []),
21+
...(args.mode ? ['--mode', args.mode] : []),
22+
...(args.verbose ? ['--verbose'] : []),
2223
...paths
2324
], { cwd, stdio: 'inherit' })
2425
}

0 commit comments

Comments
 (0)
Please sign in to comment.