@things-factory/env 6.0.7 → 6.0.31
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.
- package/lib/config.js +14 -4
- package/package.json +2 -2
package/lib/config.js
CHANGED
@@ -38,16 +38,26 @@ function build() {
|
|
38
38
|
}
|
39
39
|
|
40
40
|
function get(key, _default) {
|
41
|
-
|
41
|
+
var target = CONFIG
|
42
|
+
const keys = key.split('/')
|
43
|
+
|
44
|
+
for (var k of keys) {
|
45
|
+
target = target[k]
|
46
|
+
if (!target) {
|
47
|
+
return _default
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
return target || _default
|
42
52
|
}
|
43
53
|
|
44
54
|
function getNumber(key, _default) {
|
45
|
-
const value = Number(
|
55
|
+
const value = Number(get(key))
|
46
56
|
return isNaN(value) ? _default : value
|
47
57
|
}
|
48
58
|
|
49
|
-
function getPath(key,
|
50
|
-
var cfg = key ? get(key,
|
59
|
+
function getPath(key, _default) {
|
60
|
+
var cfg = key ? get(key, _default) : _default
|
51
61
|
|
52
62
|
return path.resolve(appRootPath, cfg)
|
53
63
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/env",
|
3
|
-
"version": "6.0.
|
3
|
+
"version": "6.0.31",
|
4
4
|
"description": "Things Factory running environment helper library",
|
5
5
|
"main": "index.js",
|
6
6
|
"author": "heartyoh@hatiolab.com",
|
@@ -27,5 +27,5 @@
|
|
27
27
|
"winston": "^3.2.1",
|
28
28
|
"winston-daily-rotate-file": "^4.2.1"
|
29
29
|
},
|
30
|
-
"gitHead": "
|
30
|
+
"gitHead": "c2faace198a68424d09412a809d716af2666c39f"
|
31
31
|
}
|