From db4dda5e8005b2e8c877a88a19c68c53a6aada92 Mon Sep 17 00:00:00 2001 From: Rafa Mel Date: Sat, 11 May 2019 18:24:29 +0200 Subject: [PATCH] fix(utils/env-manager): fixes environment variables setting and restoring when undefined --- src/utils/env-manager.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/utils/env-manager.ts b/src/utils/env-manager.ts index 2bac0be..47980ca 100644 --- a/src/utils/env-manager.ts +++ b/src/utils/env-manager.ts @@ -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; @@ -34,7 +34,9 @@ export default class EnvManager { public restore(): void { const toRestore = Object.keys(this.assigned).reduce( (acc: IOfType, 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; }, {}