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`); } }