1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var fs = require("fs");
|
4 | var path = require("path");
|
5 | var Configuration = (function () {
|
6 | function Configuration() {
|
7 | }
|
8 | Configuration.load = function (file, normalize) {
|
9 | var me = this, folder, envFile, data = {}, envData = {};
|
10 | file = fs.realpathSync(file);
|
11 | if (fs.existsSync(file)) {
|
12 | data = JSON.parse(fs.readFileSync(file).toLocaleString());
|
13 | folder = path.dirname(file);
|
14 | envFile = path.join(folder, ".env.json");
|
15 | if (fs.existsSync(envFile)) {
|
16 | envData = JSON.parse(fs.readFileSync(envFile).toLocaleString());
|
17 | }
|
18 | data = Object.assign({}, data, envData);
|
19 | if (normalize) {
|
20 | return normalize(data);
|
21 | }
|
22 | else {
|
23 | return data;
|
24 | }
|
25 | }
|
26 | else {
|
27 | throw new Error("Config file not found! " + file);
|
28 | }
|
29 | };
|
30 | return Configuration;
|
31 | }());
|
32 | exports.Configuration = Configuration;
|
33 |
|
\ | No newline at end of file |