Stringiy function for command console

This commit is contained in:
Anthony Laibe 2018-10-30 19:45:35 +01:00
parent 03a32f0434
commit 9276dd7805
1 changed files with 10 additions and 1 deletions

View File

@ -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 = [