mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 02:17:48 +00:00
Fix Tunnel#stop.
This commit is contained in:
@@ -602,13 +602,16 @@ Tunnel.prototype.start = function(callback) {
|
|||||||
console.log('Sauce Connect tunnel opened');
|
console.log('Sauce Connect tunnel opened');
|
||||||
|
|
||||||
var completed = 0,
|
var completed = 0,
|
||||||
total = tunnel.jobs.length;
|
queue = tunnel.queue,
|
||||||
|
running = tunnel.running;
|
||||||
|
|
||||||
|
push.apply(queue, tunnel.jobs);
|
||||||
|
|
||||||
|
var total = queue.length;
|
||||||
tunnel.emit('start');
|
tunnel.emit('start');
|
||||||
push.apply(tunnel.queue, tunnel.jobs);
|
|
||||||
|
|
||||||
_.invoke(tunnel.queue, 'on', 'complete', function() {
|
_.invoke(queue, 'on', 'complete', function() {
|
||||||
_.pull(tunnel.running, this);
|
_.pull(running, this);
|
||||||
if (success) {
|
if (success) {
|
||||||
success = !this.failed;
|
success = !this.failed;
|
||||||
}
|
}
|
||||||
@@ -653,8 +656,9 @@ Tunnel.prototype.stop = function(callback) {
|
|||||||
}
|
}
|
||||||
console.log('Shutting down Sauce Connect tunnel...');
|
console.log('Shutting down Sauce Connect tunnel...');
|
||||||
|
|
||||||
var stopped = 0,
|
var running = this.running,
|
||||||
total = this.jobs.length,
|
stopped = 0,
|
||||||
|
total = running.length,
|
||||||
tunnel = this;
|
tunnel = this;
|
||||||
|
|
||||||
var onTunnelStop = function() {
|
var onTunnelStop = function() {
|
||||||
@@ -665,12 +669,12 @@ Tunnel.prototype.stop = function(callback) {
|
|||||||
this.stopping = true;
|
this.stopping = true;
|
||||||
this.queue.length = 0;
|
this.queue.length = 0;
|
||||||
|
|
||||||
if (_.isEmpty(this.running)) {
|
if (!total) {
|
||||||
_.defer(onTunnelStop);
|
_.defer(onTunnelStop);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
_.invoke(this.running, 'stop', function() {
|
_.invoke(running, 'stop', function() {
|
||||||
_.pull(tunnel.running, this);
|
_.pull(running, this);
|
||||||
if (++stopped == total) {
|
if (++stopped == total) {
|
||||||
tunnel.connection.stop(onTunnelStop);
|
tunnel.connection.stop(onTunnelStop);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user