diff --git a/lib/modules/console/index.js b/lib/modules/console/index.js index 23a59f075..8ac3ba901 100644 --- a/lib/modules/console/index.js +++ b/lib/modules/console/index.js @@ -31,6 +31,14 @@ class Console { this.suggestions = new Suggestions(embark, options); } + jsonReplacer(key, value) { + if (typeof value === 'function') { + return value.toString(); + } + + return value; + } + registerApi() { let plugin = this.plugins.createPlugin('consoleApi', {}); plugin.registerAPICall('post', '/embark-api/command', (req, res) => { @@ -41,11 +49,12 @@ class Console { if (typeof result === 'string') { return res.send({result}); } - res.send({result: stringify(result, null, 2)}); + res.send({result: stringify(result, this.jsonReplacer, 2)}); }); }); } + processEmbarkCmd (cmd) { if (cmd === 'help' || cmd === __('help') || cmd === '01189998819991197253') { let helpText = [