-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (26 loc) · 810 Bytes
/
index.js
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
const path = require('path');
const utils = require('./utils');
const fsx = require('./utils/fs');
const envs = utils.env(process.env.ENV_FILE || '.env', process.env.ENV_INJECT);
let filename = process.env.CONFIG_FILE || envs.CONFIG_FILE;
if (!filename) {
filename = path.resolve(process.cwd(), 'config');
if (!fsx.isDirectory(filename)) {
filename = path.resolve(process.cwd(), 'config.json');
}
} else if (!path.isAbsolute(filename)) {
filename = path.resolve(process.cwd(), filename);
}
const config = utils.load(filename, envs);
const __ = Object.assign(
{ desolve: () => delete require.cache[__filename] },
utils
);
Object.defineProperty(config, '__', {
configurable: false,
enumerable: false,
get() {
return __;
}
});
module.exports = config;