Skip to content

Commit

Permalink
fix: no throw on unknown config value
Browse files Browse the repository at this point in the history
  • Loading branch information
amphro committed Feb 11, 2021
1 parent b214da3 commit 49618db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ export class Config extends ConfigFile<ConfigFile.Options> {
*/
private async cryptProperties(encrypt: boolean): Promise<void> {
const hasEncryptedProperties = this.entries().some(([key]) => {
return !!ensure(Config.propertyConfigMap[key]).encrypted;
return !!Config.propertyConfigMap[key]?.encrypted;
});

if (hasEncryptedProperties) {
Expand Down
9 changes: 9 additions & 0 deletions test/unit/config/configTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,15 @@ describe('Config', () => {

expect(writeStub.called).to.be.true;
});

it('calls ConfigFile.read with unknown key and does not throw on crypt', async () => {
stubMethod($$.SANDBOX, ConfigFile.prototype, ConfigFile.prototype.read.name).callsFake(async function () {
this.setContentsFromObject({ unknown: 'unknown config key and value' });
});

const config: Config = await Config.create(Config.getDefaultOptions(true));
expect(config).to.exist;
});
});

describe('allowed properties', () => {
Expand Down

0 comments on commit 49618db

Please sign in to comment.