Skip to content

Commit

Permalink
Merge branch 'release/0.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
allohamora committed Apr 11, 2023
2 parents a143f21 + 5873602 commit 7512c08
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [0.5.0](https://github.com/allohamora/config-manager/compare/0.4.0...0.5.0) (2023-04-11)

### ⚠ BREAKING CHANGES

- pickFor now every time returns EnvPicker

### Features

- pickFor now every time returns EnvPicker ([e688443](https://github.com/allohamora/config-manager/commit/e688443b8f845bb7a5049d2e3663d3c87d0c7390))

## [0.4.0](https://github.com/allohamora/config-manager/compare/0.3.0...0.4.0) (2023-04-10)

### Features
Expand Down
14 changes: 7 additions & 7 deletions __tests__/unit/env.manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ describe('EnvManager', () => {

describe('pickFor', () => {
it('returns values', () => {
expect(env.pickFor({ test: 'EMAIL' })?.value()).toBe(envStub.EMAIL);
expect(env.pickFor({ test: 'INTEGER' })?.value()).toBe(envStub.INTEGER);
expect(env.pickFor({ test: 'EMAIL' }).value()).toBe(envStub.EMAIL);
expect(env.pickFor({ test: 'INTEGER' }).value()).toBe(envStub.INTEGER);

expect(env.pickFor({ production: 'EMAIL' })?.value()).toEqual(undefined);
expect(env.pickFor({ production: 'INTEGER' })?.value()).toEqual(undefined);
expect(env.pickFor({ production: 'EMAIL' }).value()).toEqual(undefined);
expect(env.pickFor({ production: 'INTEGER' }).value()).toEqual(undefined);

expect(env.pickFor({ test: 'EMPTY_STRING' })?.value()).toEqual(undefined);
expect(env.pickFor({ test: 'SPACE_STRING' })?.value()).toEqual(undefined);
expect(env.pickFor({ test: 'OPTIONAL' })?.value()).toEqual(undefined);
expect(env.pickFor({ test: 'EMPTY_STRING' }).value()).toEqual(undefined);
expect(env.pickFor({ test: 'SPACE_STRING' }).value()).toEqual(undefined);
expect(env.pickFor({ test: 'OPTIONAL' }).value()).toEqual(undefined);
});
});

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@allohamora/config-manager",
"version": "0.4.0",
"version": "0.5.0",
"description": "config manager",
"main": "./dist/index.cjs",
"exports": {
Expand Down
4 changes: 2 additions & 2 deletions src/env/env.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ export class EnvManager<E extends string, C extends BaseConfig = BaseConfig> ext
return this.pick(key) as EnvPicker<E, C[K]>;
}

public pickFor<K extends keyof C>(envRecord: AtLeastOne<Record<E, K>>): undefined | EnvPicker<E, C[K] | undefined> {
public pickFor<K extends keyof C>(envRecord: AtLeastOne<Record<E, K>>): EnvPicker<E, C[K] | undefined> {
const key = envRecord[this.nodeEnv as E] as string | undefined;

if (!key) {
return;
return new EnvPicker(undefined, this.nodeEnv) as EnvPicker<E, undefined>;
}

return this.pick(key) as EnvPicker<E, C[K] | undefined>;
Expand Down

0 comments on commit 7512c08

Please sign in to comment.