Client.prototype._addScript = function(desc) {
this.scripts[desc.id] = desc;
- desc.isNative = (desc.name.replace('.js', '') in natives) ||
- desc.name == 'node.js';
+ if (desc.name) {
+ desc.isNative = (desc.name.replace('.js', '') in natives) ||
+ desc.name == 'node.js';
+ }
};
Client.prototype._onResponse = function(res) {
for (var i = 0; i < this._reqCallbacks.length; i++) {
var cb = this._reqCallbacks[i];
- if (this._reqCallbacks[i].request_seq == cb.request_seq) break;
+ if (this._reqCallbacks[i].request_seq == res.body.request_seq) break;
}
var self = this;
+ var handled = false;
if (res.headers.Type == 'connect') {
// Request a list of scripts for our own storage.
self.reqScripts();
self.emit('ready');
+ handled = true;
} else if (res.body && res.body.event == 'break') {
this.emit('break', res.body);
+ handled = true;
} else if (res.body && res.body.event == 'afterCompile') {
this._addHandle(res.body.body.script);
+ handled = true;
} else if (res.body && res.body.event == 'scriptCollected') {
// ???
this._removeScript(res.body.body.script);
+ handled = true;
+
+ }
- } else if (cb) {
+ if (cb) {
this._reqCallbacks.splice(i, 1);
+ handled = true;
cb(res.body);
-
- } else {
- this.emit('unhandledResponse', res.body);
}
+
+ if (!handled) this.emit('unhandledResponse', res.body);
};
self.tryQuit();
} else if (/^r(un)?/.test(cmd)) {
+ self._lastCommand = null;
if (self.child) {
self.restartQuestion(function (yes) {
if (!yes) {
client.reqContinue();
} else if (/^k(ill)?/.test(cmd)) {
+ if (!client) {
+ self.printNotConnected();
+ return;
+ }
// kill
if (self.child) {
self.killQuestion(function (yes) {