MCPcopy
hub / github.com/MagicMirrorOrg/MagicMirror / loadModule

Function loadModule

js/loader.js:144–164  ·  view source on GitHub ↗

* Load modules via ajax request and create module objects. * @param {object} module Information about the module we want to load. * @returns {Promise } resolved when module is loaded

(module)

Source from the content-addressed store, hash-verified

142 * @returns {Promise<void>} resolved when module is loaded
143 */
144async function loadModule (module) {
145 const url = module.path + module.file;
146
147 /**
148 * @returns {Promise<void>}
149 */
150 async function afterLoad () {
151 const moduleObject = Module.create(module.name);
152 if (moduleObject) {
153 await bootstrapModule(module, moduleObject);
154 }
155 }
156
157 if (loadedModuleFiles.indexOf(url) !== -1) {
158 await afterLoad();
159 } else {
160 await loadFile(url);
161 loadedModuleFiles.push(url);
162 await afterLoad();
163 }
164}
165
166/**
167 * Bootstrap modules by setting the module data and loading the scripts & styles.

Callers 1

loadModulesFunction · 0.70

Calls 2

afterLoadFunction · 0.85
loadFileFunction · 0.85

Tested by

no test coverage detected