Skip to content

Commit

Permalink
fix: do not stop piping stderr on success in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
isqua committed May 28, 2021
1 parent 5c8ccae commit b733d55
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ var Tunnel = inherit(EventEmitter, {
}

if (/success/.test(data)) {
if (!this._activityWatcher) {
if (!this._shouldBeVerbose()) {
this._tunnel.stderr.removeAllListeners('data');
}

Expand Down Expand Up @@ -162,13 +162,11 @@ var Tunnel = inherit(EventEmitter, {
},

_buildSSHArgs: function () {
var shouldBeVerbose = debug.enabled || this._activityWatcher;

return [
util.format('-R %d:localhost:%d', this.port, this._localPort),
'-N',
// heartbeat messages existence is logged to debug3 (penSSH_7.9p1, LibreSSL 2.7.3, macOC Catalina)
shouldBeVerbose ? '-vvv' : '-v',
this._shouldBeVerbose() ? '-vvv' : '-v',
this._strictHostKeyChecking === false ? '-o StrictHostKeyChecking=no' : '',
this._compression !== undefined ?
util.format('-o Compression=%s', this._compression ? 'yes' : 'no')
Expand All @@ -179,6 +177,10 @@ var Tunnel = inherit(EventEmitter, {
].filter(Boolean);
},

_shouldBeVerbose: function () {
return debug.enabled || this._activityWatcher;
},

_generateRandomPort: function (ports) {
var min = ports.min,
max = ports.max;
Expand Down

0 comments on commit b733d55

Please sign in to comment.