From d56394ad17463e15e93d712e97eccbf3b7846e6a Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Fri, 21 Aug 2015 17:35:54 +0200 Subject: Improve `exec` output type handling i.e. serialize objects to JSON. --- src/command/commands.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/command/commands.js b/src/command/commands.js index 0855e3a..d27fa58 100644 --- a/src/command/commands.js +++ b/src/command/commands.js @@ -26,8 +26,19 @@ function exec(output, args) { try { var result = eval(args.join(' ')); - if ( typeof result !== 'undefined' ) { - output.log(result); + switch ( typeof result ) { + case 'string': { + output.log(result); + break; + } + case 'number': { + output.log(result); + break; + } + case 'object': { + output.log(JSON.stringify(result)); + break; + } } } catch (exception) { output.error(exception); -- cgit v1.2.3