fix: update env validation and include newest var (#39661)

This commit is contained in:
Oliver Eyton-Williams
2020-09-24 16:34:27 +02:00
committed by GitHub
parent d33f5f82a7
commit 4f68cc3126
2 changed files with 10 additions and 4 deletions

View File

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