Permalink
Browse files

Better serialization

  • Loading branch information...
1 parent 23461a2 commit 518245570f8cb8bfc3a99dab94cc9e84203a21a8 Claudio Cicali committed Sep 28, 2012
Showing with 10 additions and 5 deletions.
  1. +9 −4 bin/jecho
  2. +1 −1 package.json
View
@@ -31,7 +31,7 @@ try {
}
program
- .version('0.1.4')
+ .version('0.1.5')
.option('-p, --port <n>', 'Port to listen to, defaults to 6767')
.option('-x, --xhr', 'Bypass WebSocket and use only XHR with CORS')
.option('-i, --info', 'Output program informations')
@@ -332,15 +332,20 @@ var jecho = {
this.wsocket.addEventListener("message", function(event) {
var command = event.data.split(" ");
+ var result;
switch (command[0]) {
case '?':
try {
- // console.log(command.slice(1).join(" "));
- _self.wsSend(JSON.stringify(eval( command.slice(1).join(" ") ), undefined, 2));
+ result = eval( command.slice(1).join(" ") );
+ _self.wsSend(JSON.stringify(result, undefined, 2));
} catch(e) {
- _self.wsSend("ERR: " + e.message);
+ if (typeof result != 'undefined') {
+ _self.wsSend(JSON.stringify(Object.getOwnPropertyNames(result).sort(), undefined, 2));
+ } else {
+ _self.wsSend("ERR: " + e.message);
+ }
}
break;
View
@@ -1,6 +1,6 @@
{
"name": "jecho",
- "version": "0.1.4",
+ "version": "0.1.5",
"description": "JavaScript remote web debugging tool",
"author": "Claudio Cicali <claudio.cicali@gmail.com>",
"main": "jecho.js",

0 comments on commit 5182455

Please sign in to comment.