Comparing version 0.2.1 to 0.3.0
@@ -0,1 +1,4 @@ | ||
var util = require("util"); | ||
util.print = process.stdout.write.bind(process.stdout); | ||
module.exports = function(grunt){ | ||
@@ -2,0 +5,0 @@ grunt.initConfig({ |
@@ -17,33 +17,25 @@ var RSVP = require("rsvp"); | ||
StepRunner.prototype.run = function(data, cb){ | ||
StepRunner.prototype.run = function(data, done){ | ||
var that = this; | ||
function getStepRunner(step){ | ||
return function(resolve, reject){ | ||
var done = function(err){ | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}; | ||
function runStep(steps, data, done){ | ||
if (steps.length === 0) { | ||
return done(); | ||
} | ||
step.call(undefined, data, done); | ||
}; | ||
} | ||
var step = steps.shift(); | ||
var promises = []; | ||
this.steps.forEach(function(step){ | ||
var runner = getStepRunner(step); | ||
var p = new RSVP.Promise(runner); | ||
promises.push(p); | ||
}); | ||
function next(){ | ||
setImmediate(function(){ | ||
runStep(steps, data, done); | ||
}); | ||
} | ||
RSVP.all(promises) | ||
.then(function(){ | ||
cb(null); | ||
}) | ||
.catch(function(err){ | ||
cb(err); | ||
step(data, function(err){ | ||
if (err) { return done(err); } | ||
return next(); | ||
}); | ||
} | ||
runStep(this.steps, data, done); | ||
}; | ||
@@ -50,0 +42,0 @@ |
{ | ||
"name": "migroose", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "migration framework for mongoosejs and MongoDB", | ||
@@ -5,0 +5,0 @@ "main": "migroose/index.js", |
@@ -16,14 +16,20 @@ var AsyncSpec = require("node-jasmine-async"); | ||
migration.step(function(data, stepComplete){ | ||
stepsRun.push(1); | ||
stepComplete(); | ||
setTimeout(function(){ | ||
stepsRun.push(1); | ||
stepComplete(); | ||
}, 50); | ||
}); | ||
migration.step(function(data, stepComplete){ | ||
stepsRun.push(2); | ||
stepComplete(); | ||
setImmediate(function(){ | ||
stepsRun.push(2); | ||
stepComplete(); | ||
}); | ||
}); | ||
migration.step(function(data, stepComplete){ | ||
stepsRun.push(3); | ||
stepComplete(); | ||
setTimeout(function(){ | ||
stepsRun.push(3); | ||
stepComplete(); | ||
}, 10); | ||
}); | ||
@@ -30,0 +36,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31949
786