/** * @Author HonorLee (dev@honorlee.me) * @Version 1.0 (2018-05-04) * @License MIT */ export default class Module{ public static init(){ //定义全局Module载入语法糖 (global as any).M = function(moduleName:string){ if(!moduleName){ LOGGER.error('Module name undefined!!'); return null; } moduleName = moduleName.toLowerCase(); // let ext = moduleName.includes('.js')?'':'.js'; // let filePath = `${_MVCRootPath.module}/${moduleName}${ext}` const filePath = `${SYSTEM.MVC.PATH.MODULE}/${moduleName}`; try{ FILE.statSync(filePath); return require(filePath); }catch(e:any){ if(e.code!='ENOENT'){ LOGGER.error('Load moduleName file error:'); if(e.stack) LOGGER.error(e.stack); }else{ LOGGER.error('No such module ['+moduleName+'],please check the moduleName file name,all letter must be lowercase'); } return null; } } } }