fix: would crash if no gpm installed

This commit is contained in:
Mario GLiewe 2015-02-01 13:15:41 +01:00
parent 96a19b8523
commit db435b179d
1 changed files with 53 additions and 49 deletions

View File

@ -102,7 +102,12 @@ function GpmClient(options) {
vc=/[0-9]+$/.exec(tty)[0];
}
var self=this;
if (tty) {
fs.stat(GPM_SOCKET, function(err, stat) {
if (err || !stat.isSocket())
return;
var conf = {
eventMask: 0xffff,
@ -124,7 +129,6 @@ function GpmClient(options) {
});
});
var self=this;
gpm.on('data', function(packet) {
var evnt=parseEvent(packet);
switch(evnt.type & 15) {
@ -154,11 +158,11 @@ function GpmClient(options) {
console.log('GPM ERROR', err);
self.stop();
});
});
}
}
GpmClient.prototype=new EventEmitter();
GpmClient.prototype.stop=function() {