aboutsummaryrefslogtreecommitdiff
path: root/src/command
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-08-21 17:35:54 +0200
committerAdrian Kummerlaender2015-08-21 17:35:54 +0200
commitd56394ad17463e15e93d712e97eccbf3b7846e6a (patch)
tree8bc311000c4d17962abb0fbead3abf5cb42d06d8 /src/command
parentad6773b267e2bbdfc5e049a4bc8ac8b92980270e (diff)
downloadMetaTerm-d56394ad17463e15e93d712e97eccbf3b7846e6a.tar
MetaTerm-d56394ad17463e15e93d712e97eccbf3b7846e6a.tar.gz
MetaTerm-d56394ad17463e15e93d712e97eccbf3b7846e6a.tar.bz2
MetaTerm-d56394ad17463e15e93d712e97eccbf3b7846e6a.tar.lz
MetaTerm-d56394ad17463e15e93d712e97eccbf3b7846e6a.tar.xz
MetaTerm-d56394ad17463e15e93d712e97eccbf3b7846e6a.tar.zst
MetaTerm-d56394ad17463e15e93d712e97eccbf3b7846e6a.zip
Improve `exec` output type handling
i.e. serialize objects to JSON.
Diffstat (limited to 'src/command')
-rw-r--r--src/command/commands.js15
1 files 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);