UNPKG

2.41 kBJavaScriptView Raw
1"use strict";
2
3var _path = _interopRequireDefault(require("path"));
4
5var _fs = _interopRequireDefault(require("fs"));
6
7var _lodash = _interopRequireDefault(require("lodash"));
8
9function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
11function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
12
13function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
14
15var ordered_modules = ['logger', 'error', 'database', 'routes', 'views'];
16
17function load() {
18 return _load.apply(this, arguments);
19}
20
21function _load() {
22 _load = _asyncToGenerator(function* () {
23 try {
24 /* console.log('loading from array')*/
25 var bootstrap_path = _path.default.resolve(_path.default.join(spice.module_root_path, '/bootstrap'));
26
27 var app_bootstrap_path = _path.default.resolve(_path.default.join(spice.root_path, '/bootstrap'));
28 /* console.log('MODULE Bootstrap directory', bootstrap_path);
29 console.log('APP Bootstrap directory', app_bootstrap_path); */
30
31
32 for (var file of ordered_modules) {
33 var mod = require(_path.default.join(bootstrap_path, file));
34
35 if (_lodash.default.isFunction(mod)) {
36 yield mod();
37 }
38
39 console.log('loaded', file);
40 }
41
42 var paths = [bootstrap_path, app_bootstrap_path];
43
44 for (var loadder_path of paths) {
45 for (var _file of _fs.default.readdirSync(loadder_path)) {
46 console.log("Loading:", _file);
47
48 if (_file != 'index.js' && !_lodash.default.includes(ordered_modules, _file.split('.')[0])) {
49 var _mod = require(_path.default.join(loadder_path, _file.split('.')[0]));
50
51 if (_lodash.default.isFunction(_mod)) {
52 yield _mod();
53 }
54 }
55 }
56 }
57 } catch (e) {
58 console.log(e.stack);
59 }
60 });
61 return _load.apply(this, arguments);
62}
63
64load();
\No newline at end of file