UNPKG

@fontoxml/fontoxml-development-tools

Version:

Development tools for Fonto.

39 lines (34 loc) 1.07 kB
import path from 'path'; export default async function addCoreModulesToApp(app, options) { // Load modules list from configuration dot-rc file. const moduleConfig = app.config.registerConfig('modules', []); // Load the core module and hide it from listing. const coreModule = await app.enableBuiltInModule( path.join(app.builtInModulesPath, 'core'), app, options ); coreModule.hidden = true; // Load the shared module and hide it from listing. const sharedModule = await app.enableBuiltInModule( path.join(app.builtInModulesPath, 'shared'), app, options ); sharedModule.hidden = true; // Load modules from configuration dot-rc file. if (Array.isArray(moduleConfig)) { for (const modulePath of moduleConfig) { try { // Resolve potentially relative module paths defined in the dot-rc file. const absoluteModulePath = path.resolve( app.config.getLocation(), modulePath, ); await app.enableModule(absoluteModulePath); } catch (err) { app.error(`${path.basename(modulePath)} modulefail`, err); } } } }