From 78d3189142ee3a5e4a5b55a04f0deb34bf43fe5c Mon Sep 17 00:00:00 2001 From: Anthony Laibe Date: Tue, 30 Oct 2018 21:05:10 +0100 Subject: [PATCH] PR feedback --- lib/modules/console/index.js | 11 +---------- lib/utils/utils.js | 11 ++++++++++- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/modules/console/index.js b/lib/modules/console/index.js index 8ac3ba901..a075f2445 100644 --- a/lib/modules/console/index.js +++ b/lib/modules/console/index.js @@ -31,14 +31,6 @@ 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) => { @@ -49,12 +41,11 @@ class Console { if (typeof result === 'string') { return res.send({result}); } - res.send({result: stringify(result, this.jsonReplacer, 2)}); + res.send({result: stringify(result, utils.jsonFunctionReplacer, 2)}); }); }); } - processEmbarkCmd (cmd) { if (cmd === 'help' || cmd === __('help') || cmd === '01189998819991197253') { let helpText = [ diff --git a/lib/utils/utils.js b/lib/utils/utils.js index e896dd4f1..6c6fbc805 100644 --- a/lib/utils/utils.js +++ b/lib/utils/utils.js @@ -524,6 +524,14 @@ function fuzzySearch(text, list, filter) { return fuzzy.filter(text, list, {extract: (filter || function () {})}); } +function jsonFunctionReplacer(_key, value) { + if (typeof value === 'function') { + return value.toString(); + } + + return value; +} + module.exports = { joinPath, dirname, @@ -570,5 +578,6 @@ module.exports = { timer, fileTreeSort, copyToClipboard, - fuzzySearch + fuzzySearch, + jsonFunctionReplacer };