mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
84f387785a
refs #6301 - fix messages that joined with comma and therefore missed outputting version no - change `logInfo` to `logger` that has both an info and a warn method - add new warn method to errors - add a warn message everytime a migration (data or fixture) gets skipped over - update logger everywhere, including tests - update tests to check logger.warn gets called
43 lines
1.2 KiB
JavaScript
43 lines
1.2 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 sequence = require('../../../utils/sequence'),
|
|
versioning = require('../../schema').versioning,
|
|
|
|
// Private
|
|
modelOptions = {context: {internal: true}},
|
|
|
|
// Public
|
|
update;
|
|
|
|
/**
|
|
* ## Update
|
|
* Handles doing subsequent updates for versions
|
|
*
|
|
* @param {Array} versions
|
|
* @param {{info: logger.info, warn: logger.warn}} logger
|
|
* @returns {Promise<*>}
|
|
*/
|
|
update = function update(versions, logger) {
|
|
logger.info('Running fixture updates');
|
|
|
|
var ops = versions.reduce(function updateToVersion(ops, version) {
|
|
var tasks = versioning.getUpdateFixturesTasks(version, logger);
|
|
|
|
if (tasks && tasks.length > 0) {
|
|
ops.push(function runVersionTasks() {
|
|
logger.info('Updating fixtures to ' + version);
|
|
return sequence(tasks, modelOptions, logger);
|
|
});
|
|
}
|
|
|
|
return ops;
|
|
}, []);
|
|
|
|
return sequence(ops, modelOptions, logger);
|
|
};
|
|
|
|
module.exports = update;
|