mirror of https://github.com/embarklabs/embark.git
Stringiy function for command console
This commit is contained in:
parent
03a32f0434
commit
9276dd7805
|
@ -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 = [
|
||||
|
|
Loading…
Reference in New Issue