feat: add block description to mobile curriculum (#45370)

* feat: add block description to mobile curriculum

* feat: add superblock names
This commit is contained in:
Sem Bauke
2022-03-22 20:11:44 +01:00
committed by GitHub
parent caaa416be0
commit 567e99231f
4 changed files with 125 additions and 11 deletions

View File

@ -177,10 +177,15 @@ async function buildBlocks({ basename: blockName }, curriculum, superBlock) {
__dirname,
`./challenges/_meta/${blockName}/meta.json`
);
let blockMeta;
try {
blockMeta = require(metaPath);
if (fs.existsSync(metaPath)) {
// try to read the file, if the meta path does not exist it should be a certification.
// As they do not have meta files.
const blockMeta = JSON.parse(fs.readFileSync(metaPath));
const { isUpcomingChange } = blockMeta;
if (typeof isUpcomingChange !== 'boolean') {
throw Error(
`meta file at ${metaPath} is missing 'isUpcomingChange', it must be 'true' or 'false'`
@ -192,10 +197,7 @@ async function buildBlocks({ basename: blockName }, curriculum, superBlock) {
const blockInfo = { meta: blockMeta, challenges: [] };
curriculum[superBlock].blocks[blockName] = blockInfo;
}
} catch (e) {
if (e.code !== 'MODULE_NOT_FOUND') {
throw e;
}
} else {
curriculum['certifications'].blocks[blockName] = { challenges: [] };
}
}