From 3d8502a96e2e3985e0a05748db589e37986b3a6a Mon Sep 17 00:00:00 2001 From: Boyan Rabchev Date: Wed, 2 Apr 2014 10:46:17 +0300 Subject: [PATCH] Fixed issue: https://github.com/rabchev/web-terminal/issues/4 --- lib/terminal.js | 9 ++++++--- package.json | 4 ++-- web/init.js | 7 ++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/terminal.js b/lib/terminal.js index a4a8c05..aedf2a8 100644 --- a/lib/terminal.js +++ b/lib/terminal.js @@ -161,8 +161,11 @@ function initialize(server, options, fn) { stdin = proc.stdin; } - proc.on("error", function (data) { - // Do nothing, we have to handle this event to prevent exceptoin bubbling. + proc.on("error", function (err) { + if (err.code === "ENOENT") { + err.message = cmd + ": command not found"; + } + socket.emit("console", err.message); }); proc.stdout.setEncoding("utf8"); @@ -178,7 +181,7 @@ function initialize(server, options, fn) { socket.emit("console", data); }); - proc.on("close", function (code, signal) { + proc.on("close", function () { stdin = null; socket.emit("exit", ""); }); diff --git a/package.json b/package.json index f485fef..0e779d2 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "web-terminal", "description": "Web-Terminal is a terminal server that provides remote CLI via standard web browser and HTTP protocol.", - "version": "0.6.3", + "version": "0.6.4", "author": "Boyan Rabchev ", - "contributors": [ + "contributors": [ { "name": "Boyan Rabchev", "email": "boyan@rabchev.com" } ], "config": { diff --git a/web/init.js b/web/init.js index be4bb9c..e5540bc 100644 --- a/web/init.js +++ b/web/init.js @@ -206,13 +206,11 @@ function convertToHtml(data) { var i, - j, chr, output = "", idx = index, seq = 0, closures = [], - closure, res; @@ -271,7 +269,6 @@ $(window.document).keydown(function (e) { var part1, part2; - var charCode = (typeof e.which === "number") ? e.which : e.keyCode; switch (e.keyCode) { case 8: // Backspace @@ -288,7 +285,7 @@ cursorPos--; moveCursor(); } - break; + return false; case 46: // Delete e.stopImmediatePropagation(); if (currentLine.length > cursorPos) { @@ -299,7 +296,7 @@ moveCursor(); } - break; + return false; case 38: // Up Arrow e.stopImmediatePropagation(); if (linePos < lines.length - 1) {