Ghost/core/frontend/services/themes/loader.js
Vikas Potluri 15d9a77092
Moved config from server to shared (#11850)
* moved `server/config` to `shared/config`
* updated config import paths in server to use shared
* updated config import paths in frontend to use shared
* updated config import paths in test to use shared
* updated config import paths in root to use shared
* trigger regression tests
* of course the rebase broke tests
2020-05-27 18:47:53 +01:00

31 lines
928 B
JavaScript

const debug = require('ghost-ignition').debug('themes:loader');
const config = require('../../../shared/config');
const packageJSON = require('../../../server/lib/fs/package-json');
const themeList = require('./list');
let loadAllThemes;
let loadOneTheme;
loadAllThemes = function loadAllThemes() {
return packageJSON.read
.all(config.getContentPath('themes'))
.then(function updateThemeList(themes) {
debug('loading themes', Object.keys(themes));
themeList.init(themes);
});
};
loadOneTheme = function loadOneTheme(themeName) {
return packageJSON.read
.one(config.getContentPath('themes'), themeName)
.then(function (readThemes) {
debug('loaded one theme', themeName);
return themeList.set(themeName, readThemes[themeName]);
});
};
module.exports = {
loadAllThemes: loadAllThemes,
loadOneTheme: loadOneTheme
};