Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add a --verbose flag to inspect command #1175

Merged
merged 1 commit into from
Apr 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions packages/@vue/cli-service/lib/commands/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module.exports = (api, options) => {
description: 'inspect internal webpack config',
usage: 'vue-cli-service inspect [options] [...paths]',
options: {
'--mode': 'specify env mode (default: development)'
'--mode': 'specify env mode (default: development)',
'--verbose': 'show full function definitions in output'
}
}, args => {
api.setMode(args.mode || 'development')
Expand All @@ -27,13 +28,15 @@ module.exports = (api, options) => {

const pluginRE = /(?:function|class) (\w+Plugin)/
console.log(stringify(res, (value, indent, stringify) => {
if (typeof value === 'function' && value.toString().length > 100) {
return `function () { /* omitted long function */ }`
}
if (value && typeof value.constructor === 'function') {
const match = value.constructor.toString().match(pluginRE)
if (match) {
return `/* ${match[1]} */ ` + stringify(value)
if (!args.verbose) {
if (typeof value === 'function' && value.toString().length > 100) {
return `function () { /* omitted long function */ }`
}
if (value && typeof value.constructor === 'function') {
const match = value.constructor.toString().match(pluginRE)
if (match) {
return `/* ${match[1]} */ ` + stringify(value)
}
}
}
return stringify(value)
Expand Down
3 changes: 2 additions & 1 deletion packages/@vue/cli/bin/vue.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ program
program
.command('inspect [paths...]')
.option('--mode <mode>')
.option('-v --verbose', 'Show full function definitions in output')
.description('inspect the webpack config in a project with vue-cli-service')
.action((paths, cmd) => {
require('../lib/inspect')(paths, cmd.mode)
require('../lib/inspect')(paths, cleanArgs(cmd))
})

program
Expand Down
5 changes: 3 additions & 2 deletions packages/@vue/cli/lib/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const path = require('path')
const execa = require('execa')
const resolve = require('resolve')

module.exports = function inspect (paths, mode) {
module.exports = function inspect (paths, args) {
const cwd = process.cwd()
let servicePath
try {
Expand All @@ -18,7 +18,8 @@ module.exports = function inspect (paths, mode) {
execa('node', [
binPath,
'inspect',
...(mode ? ['--mode', mode] : []),
...(args.mode ? ['--mode', args.mode] : []),
...(args.verbose ? ['--verbose'] : []),
...paths
], { cwd, stdio: 'inherit' })
}
Expand Down