2 个不稳定版本
| 0.2.0 | 2023年10月6日 |
|---|---|
| 0.1.0 | 2019年11月10日 |
#425 in 配置
11KB
257 行
snyk-config
这是 @snyk/config 的移植,一个有偏见的 npm 库,它从文件和环境加载配置。
它优先选择
- 以
CONF_前缀的环境变量,作为字面量或 JSON ${CONFIG_SECRET_FILE}config.${SERVICE_ENV}.jsonconfig.default.json
上面引用的 ${env_vars} 也具有默认值
CONFIG_SECRET_FILE默认为./config.secret.jsonSERVICE_ENV默认为local
加载的值将合并,例如
config.default.json:
{"buy": {"potatoes": 5}}
config.secret.json:
{"buy": {"condamns": 1}}
env
export CONF_buy__condamns=7
export CONF_debug=true
..将导致
{"buy": {"condamns": 7, "potatoes": 5}, "debug": true}
依赖项
~0.8–1.7MB
~36K SLoC