Ghost/core/server/services/themes/loader.js
Daniel Lockyer 4e69f24964
Moved package-json wrapper outside implementation folder
no issue

- we're preparing the `package-json` lib to be extracted out of Ghost into
  its own package so moving the initialization wrapper outside of the
  folder makes the process a lot easier
2021-05-06 12:56:21 +01:00

29 lines
897 B
JavaScript

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