mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
82ef700d81
refs: https://github.com/TryGhost/Team/issues/831 - We prefer async/await over promise chains because it makes the code much more readable - the Theme Service needs further work and this should make that work much easier - e.g. https://github.com/TryGhost/Team/issues/831 - e.g. fixing up the index.js file
23 lines
760 B
JavaScript
23 lines
760 B
JavaScript
const debug = require('@tryghost/debug')('themes');
|
|
const packageJSON = require('@tryghost/package-json');
|
|
|
|
const config = require('../../../shared/config');
|
|
const themeList = require('./list');
|
|
|
|
const loadAllThemes = async function loadAllThemes() {
|
|
const themes = await packageJSON.readPackages(config.getContentPath('themes'));
|
|
debug('loading themes', Object.keys(themes));
|
|
themeList.init(themes);
|
|
};
|
|
|
|
const loadOneTheme = async function loadOneTheme(themeName) {
|
|
const theme = await packageJSON.readPackage(config.getContentPath('themes'), themeName);
|
|
debug('loaded one theme', themeName);
|
|
return themeList.set(themeName, theme[themeName]);
|
|
};
|
|
|
|
module.exports = {
|
|
loadAllThemes: loadAllThemes,
|
|
loadOneTheme: loadOneTheme
|
|
};
|