Skip to content

Commit

Permalink
fix Transport#waitFor()
Browse files Browse the repository at this point in the history
  • Loading branch information
pstadler committed Nov 11, 2014
1 parent 97bff09 commit 7e529a6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/flight.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Flight.prototype = {
var future = new Future();

var task = function() {
new Fiber(function() {
Fiber(function() {
var t = process.hrtime();

var transport = new this.transportClass(this);
Expand Down
4 changes: 1 addition & 3 deletions lib/flightplan.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,7 @@ Flightplan.prototype = {
, 'with '.info + String(flightsForTask.length).magenta + ' flight(s)'.info);
this.logger.space();

new Fiber(function() {

Fiber(function() {
var t = process.hrtime();

for(var i=0, len=flightsForTask.length; i < len; i++) {
Expand Down Expand Up @@ -393,7 +392,6 @@ Flightplan.prototype = {
this.debriefingCallback();
process.exit(0);
}

}.bind(this)).run();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/remote.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RemoteFlight.prototype.__start = function() {
var task = function(host) {
var future = new Future();
var flight = new RemoteFlight(this.flightplan, this.fn);
new Fiber(function() {
Fiber(function() {
var t = process.hrtime();

var transport = new flight.transportClass(flight, host);
Expand Down
12 changes: 9 additions & 3 deletions lib/transport/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var util = require('util')
, Fiber = require('fibers')
, Future = require('fibers/future')
, prompt = require('prompt')
, commands = require('./commands');

Expand Down Expand Up @@ -303,9 +304,14 @@ Transport.prototype = {
* @return mixed
*/
waitFor: function(fn) {
var fiber = Fiber.current;
fn(function(ret) { fiber.run(ret); });
return Fiber.yield();
function task() {
var future = new Future();
fn(function(ret) {
future.return(ret);
});
return future;
}
Future.wait(task());
},

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/transport/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ShellTransport.prototype.__transfer = function(files, remoteDir, options) {
var task = function(config) {
var future = new Future();

new Fiber(function() {
Fiber(function() {
var sshFlags = (config.privateKey ? ' -i ' + config.privateKey : '');
var remoteUrl = util.format('%s%s:%s'
, (config.username ? config.username + '@' : '')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "flightplan",
"description": "Library for streamlining application deployment or systems administration tasks",
"version": "0.4.4",
"version": "0.4.5",
"author": "Patrick Stadler <[email protected]>",
"keywords": [
"deploy",
Expand Down

0 comments on commit 7e529a6

Please sign in to comment.