* Scans the theme template directory for theme settings that need force reload * * @returns {Object}
()
| 217 | * @returns {Object} |
| 218 | */ |
| 219 | async getSchema() { |
| 220 | if (!fs.existsSync(this.schemaPath)) { |
| 221 | return []; |
| 222 | } |
| 223 | const themeSchema = await parseJsonFile(this.schemaPath); |
| 224 | if (!Array.isArray(themeSchema)) { |
| 225 | return []; |
| 226 | } |
| 227 | const files = await promisify(glob)(Path.join(this.themePath, 'templates/**/*.html')); |
| 228 | const themeSettings = await Promise.all(files.map(this._fetchThemeSettings)); |
| 229 | const forceReloadIds = themeSettings.reduce((res, item) => ({ ...res, ...item }), {}); |
| 230 | for (const themeSchemaItem of themeSchema) { |
| 231 | for (const item of themeSchemaItem.settings) { |
| 232 | if (forceReloadIds[item.id]) { |
| 233 | item.force_reload = true; |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | return themeSchema; |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * Get Schema Translations |
no test coverage detected