diff options
author | Adrian Kummerlaender | 2015-08-21 17:35:54 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2015-08-21 17:35:54 +0200 |
commit | d56394ad17463e15e93d712e97eccbf3b7846e6a (patch) | |
tree | 8bc311000c4d17962abb0fbead3abf5cb42d06d8 /src | |
parent | ad6773b267e2bbdfc5e049a4bc8ac8b92980270e (diff) | |
download | MetaTerm-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')
-rw-r--r-- | src/command/commands.js | 15 |
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); |