2013-08-03 19:11:16 +04:00
|
|
|
var when = require('when'),
|
|
|
|
migration = require('../migration');
|
2013-06-16 00:52:03 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
module.exports = function (version) {
|
|
|
|
var exporter;
|
2013-06-16 00:52:03 +04:00
|
|
|
|
2013-08-03 19:11:16 +04:00
|
|
|
if (version > migration.currentVersion) {
|
|
|
|
return when.reject("Your data version is ahead of the current Ghost version. Please upgrade in order to export.");
|
|
|
|
}
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
try {
|
|
|
|
exporter = require("./" + version);
|
|
|
|
} catch (ignore) {
|
|
|
|
// Zero effs given
|
|
|
|
}
|
2013-06-16 00:52:03 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
if (!exporter) {
|
2013-08-03 19:11:16 +04:00
|
|
|
return when.reject("No exporter found for data version " + version);
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
2013-06-16 00:52:03 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
return exporter.exportData();
|
|
|
|
};
|