1 | import path from 'path';
|
2 | import { fileURLToPath } from 'url';
|
3 |
|
4 | const __filename = fileURLToPath(import.meta.url);
|
5 | const __dirname = path.dirname(__filename);
|
6 |
|
7 | export default async function addCoreModulesToApp(app, options) {
|
8 |
|
9 | const moduleConfig = app.config.registerConfig('modules', []);
|
10 |
|
11 |
|
12 | const coreModule = await app.enableBuiltInModule(
|
13 | path.join(__dirname, 'modules', 'core'),
|
14 | app,
|
15 | options
|
16 | );
|
17 | coreModule.hidden = true;
|
18 |
|
19 |
|
20 | (Array.isArray(moduleConfig) ? moduleConfig : []).map((modulePath) => {
|
21 | try {
|
22 |
|
23 | modulePath = path.resolve(app.config.getLocation(), modulePath);
|
24 | app.enableModule(modulePath);
|
25 | } catch (err) {
|
26 | app.error(`${path.basename(modulePath)} modulefail`, err);
|
27 | }
|
28 | });
|
29 | }
|