2013-06-25 15:43:15 +04:00
|
|
|
var when = require('when');
|
2013-06-16 00:52:03 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
module.exports = function (version, data) {
|
|
|
|
var importer;
|
2013-06-16 00:52:03 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
try {
|
|
|
|
importer = require("./" + version);
|
|
|
|
} catch (ignore) {
|
|
|
|
// Zero effs given
|
|
|
|
}
|
2013-06-16 00:52:03 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
if (!importer) {
|
|
|
|
return when.reject("No importer found");
|
|
|
|
}
|
2013-06-16 00:52:03 +04:00
|
|
|
|
2013-09-18 07:19:57 +04:00
|
|
|
return importer.importData(data).otherwise(function (err) {
|
|
|
|
if (err === "Unsupported version of data: 001" || err === "Unsupported version of data: 002") {
|
|
|
|
try {
|
|
|
|
importer = require("./temp.js");
|
|
|
|
} catch (ignore) {
|
|
|
|
// Zero effs given
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!importer) {
|
|
|
|
return when.reject("No importer found");
|
|
|
|
}
|
|
|
|
|
|
|
|
return importer.importData(data);
|
|
|
|
}
|
|
|
|
});
|
2013-06-25 15:43:15 +04:00
|
|
|
};
|