mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 01:41:46 +03:00
2142a9c587
* 🐛 fix direct update closes #7297 - move sitemap initialisation into sitemap handler - initialise sitemap on first request to sitemap * 🐛 fix how we pass options to migration files refs #7317 - clone options when passing them into the migration/fixture files - do not use default sequence, because it does not clone the arguments
34 lines
1.0 KiB
JavaScript
34 lines
1.0 KiB
JavaScript
// # Update Fixtures
|
|
// This module handles updating fixtures.
|
|
// This is done manually, through a series of files stored in an adjacent folder
|
|
// E.g. if we update to version 004, all the tasks in /004/ are executed
|
|
|
|
var Promise = require('bluebird'),
|
|
_ = require('lodash'),
|
|
sequence = function sequence(tasks, modelOptions, logger) {
|
|
// utils/sequence.js does not offer an option to pass cloned arguments
|
|
return Promise.reduce(tasks, function (results, task) {
|
|
return task(_.cloneDeep(modelOptions), logger)
|
|
.then(function (result) {
|
|
results.push(result);
|
|
return results;
|
|
});
|
|
}, []);
|
|
},
|
|
update;
|
|
|
|
/**
|
|
* Handles doing subsequent update for one version
|
|
*/
|
|
update = function update(tasks, logger, modelOptions) {
|
|
logger.info('Running fixture updates');
|
|
|
|
if (!tasks.length) {
|
|
return Promise.resolve();
|
|
}
|
|
|
|
return sequence(tasks, modelOptions, logger);
|
|
};
|
|
|
|
module.exports = update;
|