fix: tighten up ensure-env and env.js (#39694)

This commit is contained in:
Oliver Eyton-Williams
2020-09-25 21:10:17 +02:00
committed by GitHub
parent 3d7af80047
commit 61ba415717
2 changed files with 9 additions and 3 deletions

View File

@ -39,16 +39,16 @@ module.exports = Object.assign(locations, {
? null ? null
: stripePublicKey, : stripePublicKey,
algoliaAppId: algoliaAppId:
!algoliaAppId || algoliaAppId === 'Algolia app id from dashboard' !algoliaAppId || algoliaAppId === 'app_id_from_algolia_dashboard'
? null ? null
: algoliaAppId, : algoliaAppId,
algoliaAPIKey: algoliaAPIKey:
!algoliaAPIKey || algoliaAPIKey === 'Algolia api key from dashboard' !algoliaAPIKey || algoliaAPIKey === 'api_key_from_algolia_dashboard'
? null ? null
: algoliaAPIKey, : algoliaAPIKey,
paypalClientId: paypalClientId:
!paypalClientId || paypalClientId === 'id_from_paypal_dashboard' !paypalClientId || paypalClientId === 'id_from_paypal_dashboard'
? null ? null
: paypalClientId, : paypalClientId,
showUpcomingChanges: showUpcomingChanges && showUpcomingChanges === 'true' showUpcomingChanges: showUpcomingChanges === 'true'
}); });

View File

@ -45,6 +45,12 @@ if (FREECODECAMP_NODE_ENV === 'production') {
throw Error(`Env. variable ${key} is missing, build cannot continue`); throw Error(`Env. variable ${key} is missing, build cannot continue`);
} }
} }
if (env['environment'] !== 'production')
throw Error("Production environment should be 'production' ");
if (env['showUpcomingChanges'])
throw Error("SHOW_UPCOMING_CHANGES should never be 'true' in production");
} }
fs.writeFileSync(`${clientPath}/config/env.json`, JSON.stringify(env)); fs.writeFileSync(`${clientPath}/config/env.json`, JSON.stringify(env));