@things-factory/env 6.0.7 → 6.0.32

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.
Files changed (2) hide show
  1. package/lib/config.js +14 -4
  2. 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
- return CONFIG[key] || _default
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(CONFIG[key])
55
+ const value = Number(get(key))
46
56
  return isNaN(value) ? _default : value
47
57
  }
48
58
 
49
- function getPath(key, def) {
50
- var cfg = key ? get(key, def) : def
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.7",
3
+ "version": "6.0.32",
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": "5af6d8613bd6eab6feaa69df942ef3ddfae764fe"
30
+ "gitHead": "1b7b1eb2d2e1c0823ec69ee8160790c5da62072c"
31
31
  }