-
- // Static variable to hold the modules.
- let moodleSubsystems = null;
- let moodlePlugins = null;
-
- /**
- * Parse Moodle's JSON files containing the lists of components.
- *
- * The values are stored in the static variables because we
- * only need to load them once per transpiling run.
- */
- function loadMoodleModules() {
- moodleSubsystems = {'lib': 'core'};
- moodlePlugins = {};
- let components = fs.readFileSync('lib/components.json');
- components = JSON.parse(components);
-
- for (const [component, path] of Object.entries(components.subsystems)) {
- if (path) {
- // Prefix "core_" to the front of the subsystems.
- moodleSubsystems[path] = `core_${component}`;
- }
- }
-
- for (const [component, path] of Object.entries(components.plugintypes)) {
- if (path) {
- moodlePlugins[path] = component;
- }
- }
-
- for (const file of glob.sync('**/db/subplugins.json')) {
- var rawContents = fs.readFileSync(file);
- var subplugins = JSON.parse(rawContents);
-
- for (const [component, path] of Object.entries(subplugins.plugintypes)) {
- if (path) {
- moodlePlugins[path] = component;
- }
- }
- }
- }