mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
优化结构
This commit is contained in:
1 parent
75ebc1a746
commit
2554cf660a
34 files changed
+401
-150
No files matched your search
+11
-5
@@ -14,9 +14,15 @@ function exist(name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const superRequire = (name) => (__non_webpack_require__
|
||||
? __non_webpack_require__(root(name))
|
||||
: require(root(name)));
|
||||
const superRequire = (name) => {
|
||||
let m;
|
||||
try {
|
||||
m = require(root(name)); // eslint-disable-line import/no-dynamic-require
|
||||
} catch (e) {
|
||||
m = __non_webpack_require__(root(name)); // eslint-disable-line no-undef
|
||||
}
|
||||
return m;
|
||||
};
|
||||
|
||||
async function prepare() {
|
||||
installed = fs.readdirSync(root('.build/module'));
|
||||
@@ -26,8 +32,8 @@ async function handler() {
|
||||
for (const i of installed) {
|
||||
if (exist(`.build/module/${i}/handler.js`)) {
|
||||
superRequire(`.build/module/${i}/handler.js`);
|
||||
console.log(`Handler init: ${i}`);
|
||||
}
|
||||
console.log(`Handler init: ${i}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +41,8 @@ async function model() {
|
||||
for (const i of installed) {
|
||||
if (exist(`.build/module/${i}/model.js`)) {
|
||||
superRequire(`.build/module/${i}/model.js`);
|
||||
console.log(`Model init: ${i}`);
|
||||
}
|
||||
console.log(`Model init: ${i}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user