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

@venncity/nested-config

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@venncity/nested-config - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [1.2.2](https://github.com/venn-city/npm-shelf/compare/@venncity/nested-config@1.2.1...@venncity/nested-config@1.2.2) (2019-08-25)
### Bug Fixes
* **nested-config:** added fallback to parent when property not found ([38a9793](https://github.com/venn-city/npm-shelf/commit/38a9793))
## [1.2.1](https://github.com/venn-city/npm-shelf/compare/@venncity/nested-config@1.2.0...@venncity/nested-config@1.2.1) (2019-08-20)

@@ -8,0 +19,0 @@

4

package.json
{
"name": "@venncity/nested-config",
"version": "1.2.1",
"version": "1.2.2",
"author": "Venn Engineering",

@@ -44,3 +44,3 @@ "main": "src/nestedConfig.js",

},
"gitHead": "06cdf2e342eb415e6e87fa23e05fb3c07647fd05"
"gitHead": "e84109a501c2dfd8fe22372ba7600cda5e3e914e"
}

@@ -21,3 +21,3 @@ /* eslint-disable no-underscore-dangle,global-require */

await createFileAtPath('/inner/config/test.json', '{ "prop": "inner" }');
await createFileAtPath('/inner/package.json', '{ "prop": "123" }');
await createFileAtPath('/inner/package.json', '{ "test": "skjl" }');
const innerModulePath = await createFileAtPath('/inner/src/module.js', '{ "prop": "123" }');

@@ -32,3 +32,3 @@

await createFileAtPath('/inner/config/test.json', '{ "prop": "inner1" }');
await createFileAtPath('/inner/package.json', '{ "prop": "123" }');
await createFileAtPath('/inner/package.json', '{ "test": "skjl" }');
const firstInnerModulePath = await createFileAtPath('/inner/src/module1.js', '{ "prop": "123" }');

@@ -50,3 +50,3 @@

test('should not load or fail when no config found', async () => {
await createFileAtPath('/inner/package.json', '{ "prop": "123" }');
await createFileAtPath('/inner/package.json', '{ "test": "skjl" }');
const innerModulePath = await createFileAtPath('/inner/src/module.js', '{ "prop": "123" }');

@@ -61,3 +61,3 @@ const nestedConfig = rewire(path.join(__dirname, 'nestedConfig.js'));

await createFileAtPath('/inner/config/test.json', '{ "prop": "inner" }');
await createFileAtPath('/inner/package.json', '{ "prop": "123" }');
await createFileAtPath('/inner/package.json', '{ "test": "skjl" }');
const innerModulePath = await createFileAtPath('/inner/src/module.js', '{ "prop": "123" }');

@@ -69,2 +69,11 @@

});
test('should fallback to parent config when property not found', async () => {
await createFileAtPath('/inner/package.json', '{ "test": "skjl" }');
const innerModulePath = await createFileAtPath('/inner/src/module.js', '{ "prop": "123" }');
const nestedConfig = require('./nestedConfig')(innerModulePath);
const testValue = nestedConfig.get('prop');
expect(testValue).toEqual('outer');
});
});

@@ -75,3 +84,3 @@

await createFileAtPath('/inner/config/test.json', '{ "prop2": "inner" }');
await createFileAtPath('/inner/package.json', '{ "prop": "123" }');
await createFileAtPath('/inner/package.json', '{ "test": "skjl" }');
const innerModulePath = await createFileAtPath('/inner/src/module.js', '{ "prop2": "123" }');

@@ -84,3 +93,3 @@ const nestedConfig = require('./nestedConfig')(innerModulePath);

await createFileAtPath('/inner/config/test.json', '{ "prop2": "inner" }');
await createFileAtPath('/inner/package.json', '{ "prop": "123" }');
await createFileAtPath('/inner/package.json', '{ "test": "skjl" }');
const innerModulePath = await createFileAtPath('/inner/src/module.js', '{ "prop2": "123" }');

@@ -91,2 +100,11 @@ const nestedConfig = require('./nestedConfig')(innerModulePath);

});
test('should fallback to parent config when property not found', async () => {
await createFileAtPath('/inner/package.json', '{ "test": "skjl" }');
const innerModulePath = await createFileAtPath('/inner/src/module.js', '{ "prop": "123" }');
const nestedConfig = require('./nestedConfig')(innerModulePath);
const testValue = nestedConfig.has('prop');
expect(testValue).toBeTruthy();
});
});

@@ -93,0 +111,0 @@

@@ -41,3 +41,8 @@ process.env.ALLOW_CONFIG_MUTATIONS = true;

}
return config.get(`${packagePathToConfigKeyPrefix.get(packagePath)}.${key}`);
try {
return config.get(`${packagePathToConfigKeyPrefix.get(packagePath)}.${key}`);
} catch (e) {
console.info(`Property ${key} not found, fallback to parent config`, e);
return config.get(key);
}
},

@@ -48,5 +53,10 @@ has: (key, options = { getConfigFromParent: false }) => {

}
return config.has(`${packagePathToConfigKeyPrefix.get(packagePath)}.${key}`);
let innerConfigHas = config.has(`${packagePathToConfigKeyPrefix.get(packagePath)}.${key}`);
if (!innerConfigHas) {
console.info(`Property ${key} not found, fallback to parent config`);
innerConfigHas = config.has(key);
}
return innerConfigHas;
}
};
};
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