From 59173b346a9399416986bddbfc935be608300c80 Mon Sep 17 00:00:00 2001 From: "Nicholas Carrigan (he/him)" Date: Mon, 28 Dec 2020 20:04:22 -0800 Subject: [PATCH] fix(tools): Validate `curriculum_locale` (#40572) Adds validation for the `CURRICULUM_LOCALE` environment variable in the same way the `CLIENT_LOCALE` value is validated. Signed-off-by: nhcarrigan --- tools/scripts/build/ensure-env.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/scripts/build/ensure-env.js b/tools/scripts/build/ensure-env.js index e67dc75fca..8b1d7dc4ba 100644 --- a/tools/scripts/build/ensure-env.js +++ b/tools/scripts/build/ensure-env.js @@ -17,6 +17,14 @@ function checkClientLocale() { } } +function checkCurriculumLocale() { + if (!availableLangs.curriculum.includes(process.env.CURRICULUM_LOCALE)) { + throw Error( + `CURRICULUM_LOCALE, ${process.env.CURRICULUM_LOCALE}, is not an available language in client/i18n/allLangs.js` + ); + } +} + if (FREECODECAMP_NODE_ENV !== 'development') { const locationKeys = [ 'homeLocation', @@ -64,8 +72,10 @@ if (FREECODECAMP_NODE_ENV !== 'development') { throw Error("SHOW_UPCOMING_CHANGES should never be 'true' in production"); checkClientLocale(); + checkCurriculumLocale(); } else { checkClientLocale(); + checkCurriculumLocale(); } fs.writeFileSync(`${clientPath}/config/env.json`, JSON.stringify(env));