diff --git a/README.md b/README.md index eef148b..6299cfe 100644 --- a/README.md +++ b/README.md @@ -247,15 +247,6 @@ succeeded. Whether the flightplan is aborted or not. -### flightplan.abort() - -Calling this method will abort the flightplan and prevent any further -flights from being executed. - -```javascript -plan.abort(); -``` - diff --git a/lib/flight.js b/lib/flight.js index 9d1375f..6448aa2 100644 --- a/lib/flight.js +++ b/lib/flight.js @@ -23,6 +23,9 @@ Flight.prototype = { }, abort: function(msg) { + this.status.aborted = true; + this.status.crashRecordings = msg; + this.flightplan.abort(); throw new Error(msg); }, @@ -45,15 +48,15 @@ Flight.prototype = { try { this.fn(transport); } catch(e) { - this.status.aborted = true; - this.status.crashRecordings = e.message || null; - this.flightplan.abort(); - } - transport.close(); + this.abort(e.message); + } finally { + transport.close(); + + this.status.executionTime = process.hrtime(t); - this.status.executionTime = process.hrtime(t); + return future.return(); + } - return future.return(); }.bind(this)).run(); return future; diff --git a/lib/flightplan.js b/lib/flightplan.js index ac2bd7e..0fb6189 100644 --- a/lib/flightplan.js +++ b/lib/flightplan.js @@ -226,7 +226,6 @@ Flightplan.prototype = { return this; }, - /** * Whether the flightplan is aborted or not. * @@ -237,16 +236,6 @@ Flightplan.prototype = { return this.status.aborted; }, - /** - * Calling this method will abort the flightplan and prevent any further - * flights from being executed. - * - * ```javascript - * plan.abort(); - * ``` - * - * @method abort() - */ abort: function() { this.status.aborted = true; }, @@ -293,12 +282,11 @@ Flightplan.prototype = { var status = flight.getStatus() , flightNumber = this.logger.format('%s/%s', i+1, len).magenta - , executionTime = prettyTime(status.executionTime).magenta - , crashReason = !status.crashRecordings - ? '' - : this.logger.format('when %s', status.crashRecordings); + , executionTime = prettyTime(status.executionTime).magenta; if(flight.isAborted()) { + var crashReason = !status.crashRecordings ? '' + : this.logger.format('when %s', status.crashRecordings); this.logger.error('Flight'.error, flightNumber, 'aborted after'.error , executionTime, crashReason); this.logger.space(); diff --git a/lib/remote.js b/lib/remote.js index 88682ce..579050b 100644 --- a/lib/remote.js +++ b/lib/remote.js @@ -8,8 +8,7 @@ function RemoteFlight(flightplan, fn) { RemoteFlight.super_.call(this, flightplan, SSHTransport, fn); if(!this.flightplan.briefing()) { - this.logger.error("You can't do remote flights without a briefing."); - this.flightplan.abort(); + this.abort("You can't do remote flights without a briefing."); } } @@ -26,16 +25,15 @@ RemoteFlight.prototype.__start = function() { try { flight.fn(transport); } catch(e) { - this.status.aborted = true; - this.status.crashRecordings = e.message || null; - this.flightplan.abort(); - } - transport.close(); + this.abort(e.message); + } finally { + transport.close(); - flight.status.executionTime = process.hrtime(t); - this.status.executionTime = flight.status.executionTime; + flight.status.executionTime = process.hrtime(t); + this.status.executionTime = flight.status.executionTime; - return future.return(); + return future.return(); + } }.bind(this)).run(); return future; diff --git a/lib/transport/shell.js b/lib/transport/shell.js index 8d1534a..85f3529 100644 --- a/lib/transport/shell.js +++ b/lib/transport/shell.js @@ -45,7 +45,8 @@ ShellTransport.prototype.__exec = function(cmd, args, options) { this.logger.warn(this.logger.format('failed safely').warn, 'with exit code:', ret.code); } else { this.logger.error(this.logger.format('failed').error, 'with exit code:', ret.code); - fiber.throwInto(new Error(this.logger.format('`%s` failed on localhost', cmd.white))); + fiber.throwInto(new Error(this.logger.format('`%s` failed on %s' + , cmd.white, 'localhost'.warn))); } fiber.run(ret); }.bind(this)); diff --git a/package.json b/package.json index 4df3f81..7442aad 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "flightplan", "description": "Library for streamlining application deployment or systems administration tasks", - "version": "0.3.3", + "version": "0.3.4", "author": "Patrick Stadler ", "keywords": [ "deploy",