UNPKG

1.11 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var fs = require("fs");
4var path = require("path");
5var 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}());
32exports.Configuration = Configuration;
33//# sourceMappingURL=Configuration.js.map
\No newline at end of file