mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-05 14:00:41 -05:00
refactor: use process.env in node environments (#51110)
This commit is contained in:
committed by
GitHub
parent
c2fff83d41
commit
5f475cefa6
@@ -1,10 +1,13 @@
|
||||
import { writeFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
import fetch from 'node-fetch';
|
||||
import yaml from 'js-yaml';
|
||||
import envData from '../../../config/env.json';
|
||||
import { config } from 'dotenv';
|
||||
|
||||
import { trendingSchemaValidator } from './schema/trending-schema';
|
||||
|
||||
const { clientLocale } = envData;
|
||||
config({ path: path.resolve(__dirname, '../../../.env') });
|
||||
|
||||
const createCdnUrl = (lang: string) =>
|
||||
`https://cdn.freecodecamp.org/universal/trending/${lang}.yaml`;
|
||||
@@ -44,7 +47,11 @@ const download = async (clientLocale: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
void download(clientLocale);
|
||||
const locale = process.env.CLIENT_LOCALE;
|
||||
|
||||
if (!locale) throw Error('CLIENT_LOCALE must be set to a valid locale');
|
||||
|
||||
void download(locale);
|
||||
// TODO: remove the need to fallback to english once we're confident it's
|
||||
// unnecessary (client/i18n/config.js will need all references to 'en' removing)
|
||||
if (clientLocale !== 'english') void download('english');
|
||||
if (locale !== 'english') void download('english');
|
||||
|
||||
Reference in New Issue
Block a user