mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
9a14c2de4c
refs:cf514cdf7
- in commitcf514cdf7
we moved the loadSettings call up to the bridge - here we can call the async method, so we can remove loadSettingsSync altogether - all the tests have now been changed to use the async method
52 lines
1.8 KiB
JavaScript
52 lines
1.8 KiB
JavaScript
const config = require('../../../shared/config');
|
|
const parseYaml = require('./yaml-parser');
|
|
const SettingsPathManager = require('@tryghost/settings-path-manager');
|
|
|
|
let settingsLoader;
|
|
let routeSettings;
|
|
|
|
module.exports = {
|
|
init: async () => {
|
|
const RouteSettings = require('./route-settings');
|
|
const SettingsLoader = require('./settings-loader');
|
|
const DefaultSettingsManager = require('./default-settings-manager');
|
|
|
|
const settingsPathManager = new SettingsPathManager({type: 'routes', paths: [config.getContentPath('settings')]});
|
|
settingsLoader = new SettingsLoader({parseYaml, settingFilePath: settingsPathManager.getDefaultFilePath()});
|
|
routeSettings = new RouteSettings({
|
|
settingsLoader,
|
|
settingsPath: settingsPathManager.getDefaultFilePath(),
|
|
backupPath: settingsPathManager.getBackupFilePath()
|
|
});
|
|
const defaultSettingsManager = new DefaultSettingsManager({
|
|
type: 'routes',
|
|
extension: '.yaml',
|
|
destinationFolderPath: config.getContentPath('settings'),
|
|
sourceFolderPath: config.get('paths').defaultRouteSettings
|
|
});
|
|
|
|
return await defaultSettingsManager.ensureSettingsFileExists();
|
|
},
|
|
|
|
get loadRouteSettings() {
|
|
return settingsLoader.loadSettings.bind(settingsLoader);
|
|
},
|
|
get getDefaultHash() {
|
|
return routeSettings.getDefaultHash.bind(routeSettings);
|
|
},
|
|
|
|
/**
|
|
* Methods used in the API
|
|
*/
|
|
api: {
|
|
get setFromFilePath() {
|
|
return routeSettings.setFromFilePath.bind(routeSettings);
|
|
},
|
|
get get() {
|
|
return routeSettings.get.bind(routeSettings);
|
|
},
|
|
get getCurrentHash() {
|
|
return routeSettings.getCurrentHash.bind(routeSettings);
|
|
}
|
|
}
|
|
};
|