Merge pull request #1008 from embark-framework/bugfix/json-function

Stringiy function for command console
This commit is contained in:
Eric Mastro 2018-10-30 22:00:06 +01:00 committed by GitHub
commit fc902b6242
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -41,7 +41,7 @@ class Console {
if (typeof result === 'string') { if (typeof result === 'string') {
return res.send({result}); return res.send({result});
} }
res.send({result: stringify(result, null, 2)}); res.send({result: stringify(result, utils.jsonFunctionReplacer, 2)});
}); });
}); });
} }

View File

@ -524,6 +524,14 @@ function fuzzySearch(text, list, filter) {
return fuzzy.filter(text, list, {extract: (filter || function () {})}); return fuzzy.filter(text, list, {extract: (filter || function () {})});
} }
function jsonFunctionReplacer(_key, value) {
if (typeof value === 'function') {
return value.toString();
}
return value;
}
module.exports = { module.exports = {
joinPath, joinPath,
dirname, dirname,
@ -570,5 +578,6 @@ module.exports = {
timer, timer,
fileTreeSort, fileTreeSort,
copyToClipboard, copyToClipboard,
fuzzySearch fuzzySearch,
jsonFunctionReplacer
}; };