feat: throw error
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
2cd6e019c6
commit
ee4072526b
@ -165,7 +165,7 @@
|
|||||||
if (optional.cache && module) {
|
if (optional.cache && module) {
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
console.debug('加载模块', name, '位于', id, 'Optional', JSON.stringify(optional));
|
console.debug('Loading module', name + '(' + id + ')', 'Optional', JSON.stringify(optional));
|
||||||
// noinspection JSUnresolvedVariable
|
// noinspection JSUnresolvedVariable
|
||||||
module = {
|
module = {
|
||||||
id: id,
|
id: id,
|
||||||
@ -174,7 +174,6 @@
|
|||||||
require: exports(file.parentFile)
|
require: exports(file.parentFile)
|
||||||
};
|
};
|
||||||
cacheModules[id] = module;
|
cacheModules[id] = module;
|
||||||
try {
|
|
||||||
var cfile = _canonical(file);
|
var cfile = _canonical(file);
|
||||||
if (cfile.endsWith('.js')) {
|
if (cfile.endsWith('.js')) {
|
||||||
compileJs(module, file, optional);
|
compileJs(module, file, optional);
|
||||||
@ -182,13 +181,9 @@
|
|||||||
compileJson(module, file);
|
compileJson(module, file);
|
||||||
} else if (cfile.endsWith('.msm')) {
|
} else if (cfile.endsWith('.msm')) {
|
||||||
// noinspection ExceptionCaughtLocallyJS
|
// noinspection ExceptionCaughtLocallyJS
|
||||||
throw Error("暂不支持解析 MiaoScript 模块");
|
throw Error("Unsupported MiaoScript module!");
|
||||||
} else {
|
} else {
|
||||||
throw Error("未知的文件格式 " + cfile);
|
throw Error("Unknown file type " + cfile);
|
||||||
}
|
|
||||||
} catch (ex) {
|
|
||||||
console.console('§4警告! §c模块§a', name, '§c编译失败! §4ERR:', ex);
|
|
||||||
console.ex(ex);
|
|
||||||
}
|
}
|
||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
@ -243,12 +238,9 @@
|
|||||||
function _require(name, path, optional) {
|
function _require(name, path, optional) {
|
||||||
var file = new File(name);
|
var file = new File(name);
|
||||||
file = _isFile(file) ? file : resolve(name, path);
|
file = _isFile(file) ? file : resolve(name, path);
|
||||||
optional = Object.assign({ cache: true, warnNotFound: true }, optional);
|
optional = Object.assign({ cache: true }, optional);
|
||||||
if (file === undefined) {
|
if (file === undefined) {
|
||||||
if (optional.warnNotFound) {
|
throw Error("Can't found module", name, 'in directory', path)
|
||||||
console.console('§c目录§b', path, '§c下模块§a', name, '§c加载失败! §4未找到该模块!');
|
|
||||||
}
|
|
||||||
return { exports: {} };
|
|
||||||
}
|
}
|
||||||
// 重定向文件名称和类型
|
// 重定向文件名称和类型
|
||||||
return getCacheModule(_canonical(file), file.name.split(".")[0], file, optional);
|
return getCacheModule(_canonical(file), file.name.split(".")[0], file, optional);
|
||||||
@ -269,6 +261,6 @@
|
|||||||
parent = new File(parent);
|
parent = new File(parent);
|
||||||
}
|
}
|
||||||
var cacheModules = [];
|
var cacheModules = [];
|
||||||
console.debug("初始化 require 模块组件 父目录 ", _canonical(parent));
|
console.debug("Initialization require module... ParentDir:", _canonical(parent));
|
||||||
return exports(parent);
|
return exports(parent);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user