-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (31 loc) · 1.01 KB
/
Copy pathindex.js
File metadata and controls
37 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import allrounder from 'allrounder';
import j2s from 'json2server'
import { readdirSync } from 'fs';
import { join, sep } from 'path';
const replace = j2s.methods.replace
let globalConfig = {};
try {
globalConfig = require(process.cwd()+'/config.sample.json');
Object.assign(globalConfig, require(process.cwd()+'/config.json'));
} catch (er) {
}
replace(globalConfig, globalConfig);
const scanDir = join(process.cwd(), process.env.SCAN_DIR || 'src');
const currDir = process.cwd();
const appImport = new (require(`${scanDir}/modules/import`).default)(`${scanDir}/modules/`);
global.AppImport = appImport.load.bind(appImport);
readdirSync(__dirname).map((fl) => {
if (fl.endsWith('.json')) {
var json = require(join(__dirname, fl));
if (!json.vars) json.vars = {};
json.vars = replace(json.vars, globalConfig);
json.vars.plat = { scanDir, currDir, sep };
}
});
const initOptions = {
jsondir : __dirname,
debug: "unhandledRejection",
insecure: 1,
};
allrounder.init(initOptions);
allrounder.start();