Skip to content

Commit fd87394

Browse files
committed
feat: improve inspect output
1 parent 70939ef commit fd87394

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,18 @@ module.exports = (api, options) => {
2525
res = config
2626
}
2727

28-
// TODO improve stringification for loaders, plugins etc.
29-
console.log(stringify(res, null, 2))
28+
const pluginRE = /(?:function|class) (\w+Plugin)/
29+
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)
37+
}
38+
}
39+
return stringify(value)
40+
}, 2))
3041
})
3142
}

0 commit comments

Comments
 (0)