Skip to content

Commit

Permalink
Only detatch usb listeners if we have a usb controller
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyman727 committed Oct 26, 2015
1 parent bc9c59f commit 706bb9a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/usb_connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ util.inherits(USB.Scanner, EventEmitter);

USB.Scanner.prototype.start = function() {
var self = this;
if (usb) {
if (haveusb) {
usb.getDeviceList().forEach(deviceInspector);

usb.on('attach', deviceInspector);
Expand All @@ -336,7 +336,9 @@ USB.Scanner.prototype.start = function() {
};

USB.Scanner.prototype.stop = function() {
usb.removeAllListeners('attach');
if (haveusb) {
usb.removeAllListeners('attach');
}
};

module.exports.startScan = startScan;
Expand Down

0 comments on commit 706bb9a

Please sign in to comment.