Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Calling `.close()` on a closed port, trow an exception. This happens when you try to open a non existent port. This patch fixes.
  • Loading branch information
brugnara committed Sep 15, 2014
1 parent 5029dc2 commit b188e98
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/modem.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ var createModem = function() {

modem.close = function(device) {
this.port.removeAllListeners();
this.port.close();
if (this.isOpened) {
this.port.close();
}
this.port = null;
this.isOpened = false;
this.emit('close');
Expand Down

0 comments on commit b188e98

Please sign in to comment.