1 | 'use strict';
|
2 |
|
3 | const path = require('path');
|
4 |
|
5 | module.exports = function addCoreModulesToApp(app, options) {
|
6 |
|
7 | const moduleConfig = app.config.registerConfig('modules', null, () => {
|
8 |
|
9 | return (
|
10 | app.modules
|
11 |
|
12 | .filter(mod => app.builtInModules.indexOf(mod) === -1)
|
13 |
|
14 | .map(mod => mod.getInfo().path)
|
15 | );
|
16 | });
|
17 |
|
18 |
|
19 | const coreModule = app.enableBuiltInModule(
|
20 | path.join(__dirname, 'modules', 'core'),
|
21 | app,
|
22 | options
|
23 | );
|
24 | coreModule.hidden = true;
|
25 |
|
26 |
|
27 | (Array.isArray(moduleConfig) ? moduleConfig : []).map(modulePath => {
|
28 | try {
|
29 | app.enableModule(modulePath);
|
30 | } catch (err) {
|
31 | app.error(path.basename(modulePath) + ' modulefail', err);
|
32 | }
|
33 | });
|
34 | };
|