forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-challenges.js
More file actions
33 lines (27 loc) · 918 Bytes
/
Copy pathget-challenges.js
File metadata and controls
33 lines (27 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const fs = require('fs');
const path = require('path');
const util = require('util');
const { curriculum: curriculumLangs } =
require('../shared/config/i18n').availableLangs;
const { buildCurriculum } = require('./build-curriculum');
const access = util.promisify(fs.access);
exports.getChallengesForLang = async function getChallengesForLang(
lang,
filters
) {
const invalidLang = !curriculumLangs.includes(lang);
if (invalidLang)
throw Error(`${lang} is not a accepted language.
Accepted languages are ${curriculumLangs.join(', ')}`);
return buildCurriculum(lang, filters);
};
async function hasEnglishSource(basePath, translationPath) {
const englishRoot = path.resolve(__dirname, basePath, 'english');
return await access(
path.join(englishRoot, translationPath),
fs.constants.F_OK
)
.then(() => true)
.catch(() => false);
}
exports.hasEnglishSource = hasEnglishSource;