From 6734776153f4dc6550a6688bb39fc427c03d1a47 Mon Sep 17 00:00:00 2001 From: ziajka Date: Tue, 29 Jan 2019 09:54:26 +0100 Subject: [PATCH] Update prod env only when variables are defined --- set-variables-in-env.js | 12 ++++++++---- src/environments/environment.prod.ts | 3 +-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/set-variables-in-env.js b/set-variables-in-env.js index b1e3833e..04f4a067 100644 --- a/set-variables-in-env.js +++ b/set-variables-in-env.js @@ -8,10 +8,14 @@ if(argv.set) { const envFile = argv.set; console.log(`Backuping up '${envFile}' into '${tempFile}'.`); fs.copyFileSync(envFile, tempFile); - const content = fs.readFileSync(envFile, "utf8"); - const variables = `solarputty_download_url: '${process.env.SOLARPUTTY_DOWNLOAD_URL}',` - const replaced = content.replace('//ENV', variables); - fs.writeFileSync(envFile, replaced); + let content = fs.readFileSync(envFile, "utf8"); + + if(process.env.SOLARPUTTY_DOWNLOAD_URL) { + const variables = `solarputty_download_url: '${process.env.SOLARPUTTY_DOWNLOAD_URL}',` + content = content.replace('solarputty_download_url: "",', variables); + } + + fs.writeFileSync(envFile, content); } if(argv.unset) { diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index d8eafc7b..cd119730 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -1,7 +1,6 @@ export const environment = { - /* Below configuration is replaced during build time, don't remove. */ - //ENV production: true, electron: false, githubio: false, + solarputty_download_url: "", };