Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@travetto/config

Package Overview
Dependencies
Maintainers
1
Versions
297
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@travetto/config - npm Package Compare versions

Comparing version 0.0.20 to 0.0.21

4

package.json

@@ -12,3 +12,3 @@ {

"description": "",
"license": "ISC",
"license": "MIT",
"main": "index.ts",

@@ -20,3 +20,3 @@ "name": "@travetto/config",

"scripts": {},
"version": "0.0.20"
"version": "0.0.21"
}

@@ -7,4 +7,2 @@ import { bulkRead, bulkReadSync, AppEnv, bulkFindSync } from '@travetto/base';

const ENV_SEP = '_';
export class ConfigLoader {

@@ -28,3 +26,3 @@

- External config file -> loaded from env
- Environment vars -> Overrides everything
- Environment vars -> Overrides everything (happens at bind time)
*/

@@ -70,9 +68,2 @@ static initialize() {

// Handle process.env
for (const k of Object.keys(process.env)) {
if (k.includes(ENV_SEP)) { // Require at least one level
this.map.putCaseInsensitivePath(k.split(ENV_SEP), process.env[k] as string);
}
}
if (!process.env.QUIET_CONFIG && !AppEnv.test) {

@@ -79,0 +70,0 @@ console.log('Configured', this.map.toJSON());

@@ -31,2 +31,4 @@ import { deepAssign, isPlainObject, isSimple } from '@travetto/base';

const ENV_SEP = '_';
export class ConfigMap {

@@ -48,7 +50,7 @@

putCaseInsensitivePath(parts: string[], value: Prim) {
static putCaseInsensitivePath(data: Nested, parts: string[], value: Prim) {
console.log('Setting', parts, value);
parts = parts.slice(0);
let key = parts.pop()!;
let data = this.storage;

@@ -61,3 +63,3 @@ if (!key) {

const part = parts.shift()!;
const next = ConfigMap.getKeyName(part, data);
const next = this.getKeyName(part, data);
if (!next) {

@@ -74,3 +76,3 @@ return false;

key = ConfigMap.getKeyName(key, data) || key;
key = this.getKeyName(key, data) || key;
data[key] = coerce(value, data[key]);

@@ -87,3 +89,15 @@

}
return deepAssign(obj, sub);
const conf = deepAssign(obj, sub);
// Handle process.env on bind as the structure we need may not
// fully exist until the config has been created
const matcher = new RegExp(`^${key.replace(/[.]/g, '_')}`, 'i');
for (const k of Object.keys(process.env)) {
if (k.includes(ENV_SEP) && matcher.test(k)) { // Require at least one level
ConfigMap.putCaseInsensitivePath(conf, k.substring(key.length + 1).split(ENV_SEP), process.env[k] as string);
}
}
return conf;
}

@@ -90,0 +104,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc