Skip to content

Commit

Permalink
feat: improve inspect output
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Feb 2, 2018
1 parent 70939ef commit fd87394
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/@vue/cli-service/lib/commands/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,18 @@ module.exports = (api, options) => {
res = config
}

// TODO improve stringification for loaders, plugins etc.
console.log(stringify(res, null, 2))
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)
}
}
return stringify(value)
}, 2))
})
}

0 comments on commit fd87394

Please sign in to comment.