update files

This commit is contained in:
nuintun
2016-01-14 10:06:49 +08:00
parent bf76db01b9
commit e974150bb3
2 changed files with 33 additions and 34 deletions

View File

@@ -14,15 +14,29 @@ var threadKill = require('./thread-kill');
*/
function Emulator(task){
this.task = task;
this.thread = null;
this.connected = false;
}
Emulator.prototype = {
start: function (){
var context = this;
this.thread = spawn(this.task.command, {
env: this.task.env,
cwd: this.task.cwd
});
this.thread.stderr.on('data', function (){
context.stop();
});
this.thread.on('close', function (){
context.stop();
});
this.connected = true;
return this.thread;
},
stop: function (){
@@ -35,6 +49,7 @@ Emulator.prototype = {
});
context.thread = null;
context.connected = false;
});
}
}