astroboy
Version:
Astroboy(阿童木)is a Nodejs SFB(Separation of Front and Back ends) framework, built on koa2.
26 lines • 949 B
JavaScript
;
const Loader_1 = require("../core/Loader");
class AstroboyLibLoader extends Loader_1.Loader {
async load() {
let libs = {};
for (const item of this.dirs) {
try {
const indexFile = require.resolve(`${item.baseDir}/app/lib/index`);
libs[item.name] = require(indexFile);
}
catch (_err) {
const entries = await this.globDir(item.baseDir, this.config.pattern || []);
if (entries.length > 0) {
libs[item.name] = {};
entries.forEach(entry => {
const key = this.resolveExtensions(entry.split('lib/')[1], true);
libs[item.name][key] = require(entry);
});
}
}
}
this.app.libs = libs;
}
}
module.exports = AstroboyLibLoader;
//# sourceMappingURL=AstroboyLibLoader.js.map