mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-11 14:24:24 +00:00
PR feedback
This commit is contained in:
parent
9276dd7805
commit
78d3189142
@ -31,14 +31,6 @@ class Console {
|
|||||||
this.suggestions = new Suggestions(embark, options);
|
this.suggestions = new Suggestions(embark, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonReplacer(key, value) {
|
|
||||||
if (typeof value === 'function') {
|
|
||||||
return value.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
registerApi() {
|
registerApi() {
|
||||||
let plugin = this.plugins.createPlugin('consoleApi', {});
|
let plugin = this.plugins.createPlugin('consoleApi', {});
|
||||||
plugin.registerAPICall('post', '/embark-api/command', (req, res) => {
|
plugin.registerAPICall('post', '/embark-api/command', (req, res) => {
|
||||||
@ -49,12 +41,11 @@ class Console {
|
|||||||
if (typeof result === 'string') {
|
if (typeof result === 'string') {
|
||||||
return res.send({result});
|
return res.send({result});
|
||||||
}
|
}
|
||||||
res.send({result: stringify(result, this.jsonReplacer, 2)});
|
res.send({result: stringify(result, utils.jsonFunctionReplacer, 2)});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
processEmbarkCmd (cmd) {
|
processEmbarkCmd (cmd) {
|
||||||
if (cmd === 'help' || cmd === __('help') || cmd === '01189998819991197253') {
|
if (cmd === 'help' || cmd === __('help') || cmd === '01189998819991197253') {
|
||||||
let helpText = [
|
let helpText = [
|
||||||
|
@ -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
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user