@@ -249,60 +249,57 @@ function loadFile (fileName) {
249249
250250/* Public Methods */
251251
252- export const Loader = {
253-
254- /**
255- * Load all modules as defined in the config.
256- */
257- async loadModules ( ) {
258- const moduleData = await getModuleData ( ) ;
259- const envVars = await getEnvVars ( ) ;
260- const customCss = envVars . customCss ;
261-
262- // Load all modules
263- for ( const module of moduleData ) {
264- await loadModule ( module ) ;
265- }
252+ /**
253+ * Load all modules as defined in the config.
254+ */
255+ export async function loadModules ( ) {
256+ const moduleData = await getModuleData ( ) ;
257+ const envVars = await getEnvVars ( ) ;
258+ const customCss = envVars . customCss ;
266259
267- // Load custom.css
268- // Since this happens after loading the modules,
269- // it overwrites the default styles.
270- await loadFile ( customCss ) ;
260+ // Load all modules
261+ for ( const module of moduleData ) {
262+ await loadModule ( module ) ;
263+ }
271264
272- // Start all modules.
273- await startModules ( ) ;
274- } ,
265+ // Load custom.css
266+ // Since this happens after loading the modules,
267+ // it overwrites the default styles.
268+ await loadFile ( customCss ) ;
275269
276- /**
277- * Load a file (script or stylesheet).
278- * Prevent double loading and search for files defined in js/vendor.js.
279- * @param {string } fileName Path of the file we want to load.
280- * @param {Module } module The module that calls the loadFile function.
281- * @returns {Promise } resolved when the file is loaded
282- */
283- loadFileForModule ( fileName , module ) {
284- if ( loadedFiles . indexOf ( fileName . toLowerCase ( ) ) !== - 1 ) {
285- Log . log ( `File already loaded: ${ fileName } ` ) ;
286- return Promise . resolve ( ) ;
287- }
270+ // Start all modules.
271+ await startModules ( ) ;
272+ }
288273
289- if ( fileName . indexOf ( "http://" ) === 0 || fileName . indexOf ( "https://" ) === 0 || fileName . indexOf ( "/" ) !== - 1 ) {
290- // This is an absolute or relative path.
291- // Load it and then return.
292- loadedFiles . push ( fileName . toLowerCase ( ) ) ;
293- return loadFile ( fileName ) ;
294- }
274+ /**
275+ * Load a file (script or stylesheet).
276+ * Prevent double loading and search for files defined in js/vendor.js.
277+ * @param {string } fileName Path of the file we want to load.
278+ * @param {Module } module The module that calls the loadFile function.
279+ * @returns {Promise } resolved when the file is loaded
280+ */
281+ export function loadFileForModule ( fileName , module ) {
282+ if ( loadedFiles . indexOf ( fileName . toLowerCase ( ) ) !== - 1 ) {
283+ Log . log ( `File already loaded: ${ fileName } ` ) ;
284+ return Promise . resolve ( ) ;
285+ }
295286
296- if ( vendor [ fileName ] !== undefined ) {
297- // This file is defined in js/vendor.js .
298- // Load it from its location .
299- loadedFiles . push ( fileName . toLowerCase ( ) ) ;
300- return loadFile ( ` ${ vendor [ fileName ] } ` ) ;
301- }
287+ if ( fileName . indexOf ( "http://" ) === 0 || fileName . indexOf ( "https://" ) === 0 || fileName . indexOf ( "/" ) !== - 1 ) {
288+ // This is an absolute or relative path .
289+ // Load it and then return .
290+ loadedFiles . push ( fileName . toLowerCase ( ) ) ;
291+ return loadFile ( fileName ) ;
292+ }
302293
303- // File not loaded yet.
304- // Load it based on the module path.
294+ if ( vendor [ fileName ] !== undefined ) {
295+ // This file is defined in js/vendor.js.
296+ // Load it from its location.
305297 loadedFiles . push ( fileName . toLowerCase ( ) ) ;
306- return loadFile ( module . file ( fileName ) ) ;
298+ return loadFile ( ` ${ vendor [ fileName ] } ` ) ;
307299 }
308- } ;
300+
301+ // File not loaded yet.
302+ // Load it based on the module path.
303+ loadedFiles . push ( fileName . toLowerCase ( ) ) ;
304+ return loadFile ( module . file ( fileName ) ) ;
305+ }
0 commit comments