mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 02:11:44 +03:00
00c324fa4e
- Represents that logging is shared across all parts of Ghost at present
* moved core/server/lib/common/logging to core/shared/logging
* updated logging path for generic imports
* updated migration and schema imports of logging
* updated tests and index logging import
* 🔥 removed logging from common module
* fixed tests
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
const {events, i18n} = require('../../../server/lib/common');
|
|
const logging = require('../../../shared/logging');
|
|
const errors = require('@tryghost/errors');
|
|
const active = require('./active');
|
|
|
|
function activate(loadedTheme, checkedTheme, error) {
|
|
// no need to check the score, activation should be used in combination with validate.check
|
|
// Use the two theme objects to set the current active theme
|
|
try {
|
|
let previousGhostAPI;
|
|
|
|
if (active.get()) {
|
|
previousGhostAPI = active.get().engine('ghost-api');
|
|
}
|
|
|
|
active.set(loadedTheme, checkedTheme, error);
|
|
const currentGhostAPI = active.get().engine('ghost-api');
|
|
|
|
events.emit('services.themes.activated');
|
|
|
|
if (previousGhostAPI !== undefined && (previousGhostAPI !== currentGhostAPI)) {
|
|
events.emit('services.themes.api.changed');
|
|
const siteApp = require('../../../server/web/site/app');
|
|
siteApp.reload();
|
|
}
|
|
} catch (err) {
|
|
logging.error(new errors.InternalServerError({
|
|
message: i18n.t('errors.middleware.themehandler.activateFailed', {theme: loadedTheme.name}),
|
|
err: err
|
|
}));
|
|
}
|
|
}
|
|
|
|
module.exports = activate;
|