1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /**
- * @Author HonorLee (dev@honorlee.me)
- * @Version 1.0 (2018-05-04)
- * @License MIT
- */
- module.exports = {
- __construct:function(){
- (global as any).H = function(healperName:string){
- if(!healperName){
- LOGGER.error('Helper name undefined!!');
- return null;
- }
- healperName = healperName.toLowerCase();
- const ext = healperName.includes('.js')?'':'.js';
- let filePath = `${SYSTEM.PATH.Helper}/${healperName}${ext}`
- try{
- FILE.statSync(filePath);
- return require(filePath);
- }catch(e:any){
- if(e.code!='ENOENT'){
- LOGGER.error('Load help file error:');
- LOGGER.error(e.stack);
- return;
- }
- filePath = `${SYSTEM.PATH.CoreHelper}/${healperName}${ext}`
- try{
- FILE.statSync(filePath);
- return require(filePath);
- }catch(e:any){
- if(e.code!='ENOENT'){
- LOGGER.error('Load help file error:');
- LOGGER.error(e.stack);
- }else{
- LOGGER.error('No such helper ['+healperName+'],please check the helper file name,all letter must be lowercase');
- }
- return null;
- }
- }
- }
- }
- }
|