From 4f68cc312649658dfd2c990551b13c3a1270ca1c Mon Sep 17 00:00:00 2001 From: Oliver Eyton-Williams Date: Thu, 24 Sep 2020 16:34:27 +0200 Subject: [PATCH] fix: update env validation and include newest var (#39661) --- config/env.js | 2 +- tools/scripts/build/ensure-env.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/config/env.js b/config/env.js index 805336b167..af73df467b 100644 --- a/config/env.js +++ b/config/env.js @@ -50,5 +50,5 @@ module.exports = Object.assign(locations, { !paypalClientId || paypalClientId === 'id_from_paypal_dashboard' ? null : paypalClientId, - showUpcomingChanges: showUpcomingChanges === 'true' + showUpcomingChanges: showUpcomingChanges && showUpcomingChanges === 'true' }); diff --git a/tools/scripts/build/ensure-env.js b/tools/scripts/build/ensure-env.js index de00f35d61..cef67416a7 100644 --- a/tools/scripts/build/ensure-env.js +++ b/tools/scripts/build/ensure-env.js @@ -15,7 +15,12 @@ if (FREECODECAMP_NODE_ENV === 'production') { 'forumLocation', 'newsLocation' ]; - const deploymentKeys = ['locale', 'deploymentEnv', 'environment']; + const deploymentKeys = [ + 'locale', + 'deploymentEnv', + 'environment', + 'showUpcomingChanges' + ]; const searchKeys = ['algoliaAppId', 'algoliaAPIKey']; const donationKeys = ['stripePublicKey', 'paypalClientId']; @@ -29,13 +34,14 @@ if (FREECODECAMP_NODE_ENV === 'production') { variables.sort(); if (expectedVariables.length !== variables.length) { throw Error(`Env. variable validation failed. Expected - ${variables} to match ${expectedVariables} + but recieved + ${variables} `); } for (const key of expectedVariables) { - if (!env[key]) { + if (typeof env[key] === 'undefined' || env[key] === null) { throw Error(`Env. variable ${key} is missing, build cannot continue`); } }