fix(cli): customInspect works on functions (#7670)

Fixes #7650
This commit is contained in:
Kitson Kelly 2020-09-25 21:36:26 +10:00 committed by GitHub
parent 01147fab80
commit fd1c913985
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -193,6 +193,11 @@
}
function inspectFunction(value, _ctx) {
if (customInspect in value && typeof value[customInspect] === "function") {
try {
return String(value[customInspect]());
} catch {}
}
// Might be Function/AsyncFunction/GeneratorFunction
const cstrName = Object.getPrototypeOf(value).constructor.name;
if (value.name && value.name !== "anonymous") {