Skip to content

Commit

Permalink
fix(utils/env-manager): fixes environment variables setting and resto…
Browse files Browse the repository at this point in the history
…ring when undefined
  • Loading branch information
rafamel committed May 11, 2019
1 parent c4333be commit db4dda5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/utils/env-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class EnvManager {
return this.env[key] || undefined;
}
public set(key: string, value?: string): void {
this.assign({ [key]: value });
this.assign({ [key]: value || '' });
}
public default(key: string, value: string): string {
return this.get(key) || this.set(value) || value;
Expand All @@ -34,7 +34,9 @@ export default class EnvManager {
public restore(): void {
const toRestore = Object.keys(this.assigned).reduce(
(acc: IOfType<string | undefined>, key) => {
if (this.env[key] === this.assigned[key]) acc[key] = this.initial[key];
if (this.env[key] === this.assigned[key]) {
acc[key] = this.initial[key] || '';
}
return acc;
},
{}
Expand Down

0 comments on commit db4dda5

Please sign in to comment.