1 | "use strict";
|
2 |
|
3 | var _path = _interopRequireDefault(require("path"));
|
4 |
|
5 | var _fs = _interopRequireDefault(require("fs"));
|
6 |
|
7 | var _lodash = _interopRequireDefault(require("lodash"));
|
8 |
|
9 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10 |
|
11 | function 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 |
|
13 | function _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 |
|
15 | var ordered_modules = ['logger', 'error', 'database', 'routes', 'views'];
|
16 |
|
17 | function load() {
|
18 | return _load.apply(this, arguments);
|
19 | }
|
20 |
|
21 | function _load() {
|
22 | _load = _asyncToGenerator(function* () {
|
23 | try {
|
24 |
|
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 | |
29 |
|
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 |
|
64 | load(); |
\ | No newline at end of file |