sequelize-fixtures
Advanced tools
Comparing version 0.4.2 to 0.4.3
31
index.js
@@ -16,3 +16,3 @@ var Loader = require('./lib/loader'), | ||
} else { | ||
var fixtures = arguments[0], models = arguments[1], options, cb, i; | ||
var fixtures = arguments[0], models = arguments[1], options, i, cb, promise; | ||
for(i = 2; i < arguments.length; i++) { | ||
@@ -22,3 +22,14 @@ if (typeof arguments[i] === 'object') options = arguments[i]; | ||
} | ||
return fn(fixtures, models, initopts(options), cb); | ||
promise = fn(fixtures, models, initopts(options)); | ||
if (cb) { | ||
console.warn("Sequelize-fixtures: callback arguments are deprecated, please use returned promises."); | ||
promise.then(function () { | ||
cb(); | ||
}, function (err) { | ||
cb(err); | ||
}).catch(function (err){ | ||
cb(err); | ||
}); | ||
} | ||
return promise; | ||
} | ||
@@ -28,24 +39,24 @@ }; | ||
exports.loadFixture = wrap(function(fixture, models, options, cb) { | ||
exports.loadFixture = wrap(function(fixture, models, options) { | ||
var loader = new Loader(options); | ||
return loader.loadFixture(fixture, models, cb); | ||
return loader.loadFixture(fixture, models); | ||
}); | ||
exports.loadFixtures = wrap(function(fixtures, models, options, cb) { | ||
exports.loadFixtures = wrap(function(fixtures, models, options) { | ||
var loader = new Loader(options); | ||
return loader.loadFixtures(fixtures, models, cb); | ||
return loader.loadFixtures(fixtures, models); | ||
}); | ||
exports.loadFile = wrap(function(filename, models, options, cb) { | ||
exports.loadFile = wrap(function(filename, models, options) { | ||
var loader = new Loader(options), reader = new Reader(options); | ||
return reader.readFileGlob(filename).then(function(fixtures) { | ||
return loader.loadFixtures(fixtures, models, cb); | ||
return loader.loadFixtures(fixtures, models); | ||
}); | ||
}); | ||
exports.loadFiles = wrap(function(filenames, models, options, cb) { | ||
exports.loadFiles = wrap(function(filenames, models, options) { | ||
var loader = new Loader(options), reader = new Reader(options); | ||
return reader.readFiles(filenames).then(function(fixtures){ | ||
return loader.loadFixtures(fixtures, models, cb); | ||
return loader.loadFixtures(fixtures, models); | ||
}); | ||
}); |
@@ -9,11 +9,9 @@ var Promise = require('bluebird'); | ||
Loader.prototype.loadFixtures = function(fixtures, models, cb) { | ||
Loader.prototype.loadFixtures = function(fixtures, models) { | ||
return Promise.each(fixtures, function(fixture) { | ||
return this.loadFixture(fixture, models); | ||
}.bind(this)).then(function() { | ||
if (cb) cb(); | ||
}); | ||
}.bind(this)); | ||
}; | ||
Loader.prototype.loadFixture = function(fixture, models, cb) { | ||
Loader.prototype.loadFixture = function(fixture, models) { | ||
var buildOptions = fixture.buildOptions, | ||
@@ -78,4 +76,2 @@ saveOptions = fixture.saveOptions, | ||
}); | ||
}).then(function() { | ||
if (cb) cb(); | ||
}).catch(onError); | ||
@@ -82,0 +78,0 @@ }); |
{ | ||
"name": "sequelize-fixtures", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "sequelize fixture loader", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "./node_modules/.bin/mocha tests" | ||
"test": "rm -f ./testdb.sqlite && ./node_modules/.bin/mocha tests" | ||
}, | ||
@@ -9,0 +9,0 @@ "engines": { |
@@ -0,1 +1,3 @@ | ||
[![Build Status](https://travis-ci.org/domasx2/sequelize-fixtures.svg?branch=master)](https://travis-ci.org/domasx2/sequelize-fixtures) | ||
Sequelize fixtures | ||
@@ -2,0 +4,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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
349
37075
754
1