cgserver 9.2.2 → 9.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,14 +4,13 @@ exports.Config = void 0;
|
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const jsonc_1 = require("jsonc");
|
|
6
6
|
class Config {
|
|
7
|
-
_suffix = "";
|
|
8
7
|
_is_init = false;
|
|
9
8
|
_file_name = "";
|
|
10
9
|
/**
|
|
11
10
|
* 是否是debug调试模式,主要区别于读取数据档,debug默认读取file_d文件,release默认读取file_r文件,如果不存在都会读取file文件
|
|
12
11
|
*/
|
|
13
12
|
static debug = false;
|
|
14
|
-
static rootDataDir = "data
|
|
13
|
+
static rootDataDir = "data";
|
|
15
14
|
constructor(filename) {
|
|
16
15
|
this._file_name = filename;
|
|
17
16
|
}
|
|
@@ -19,27 +18,18 @@ class Config {
|
|
|
19
18
|
if (this._is_init) {
|
|
20
19
|
return false;
|
|
21
20
|
}
|
|
22
|
-
|
|
21
|
+
if (Config.rootDataDir.endsWith("/")) {
|
|
22
|
+
Config.rootDataDir = Config.rootDataDir.substring(0, Config.rootDataDir.length - 1);
|
|
23
|
+
}
|
|
24
|
+
let suffix2 = "/";
|
|
23
25
|
if (Config.debug) {
|
|
24
|
-
suffix2 = "_d";
|
|
26
|
+
suffix2 = "_d/";
|
|
25
27
|
}
|
|
26
|
-
let path = Config.rootDataDir +
|
|
28
|
+
let path = Config.rootDataDir + suffix2 + this._file_name + ".json";
|
|
27
29
|
path = path.toLowerCase();
|
|
28
30
|
if (!fs.existsSync(path)) {
|
|
29
|
-
path
|
|
30
|
-
|
|
31
|
-
if (!fs.existsSync(path)) {
|
|
32
|
-
path = Config.rootDataDir + this._file_name + suffix2 + ".json";
|
|
33
|
-
path = path.toLowerCase();
|
|
34
|
-
if (!fs.existsSync(path)) {
|
|
35
|
-
path = Config.rootDataDir + this._file_name + ".json";
|
|
36
|
-
path = path.toLowerCase();
|
|
37
|
-
if (!fs.existsSync(path)) {
|
|
38
|
-
console.error(path + " not exist!");
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
31
|
+
console.error(path + " not exist!");
|
|
32
|
+
return false;
|
|
43
33
|
}
|
|
44
34
|
let content = fs.readFileSync(path).toString();
|
|
45
35
|
let jsonData = jsonc_1.jsonc.parse(content);
|