MCPcopy Create free account
hub / github.com/freeCodeCamp/freeCodeCamp / validateBlocks

Function validateBlocks

curriculum/src/build-curriculum.ts:364–389  ·  view source on GitHub ↗
(superblocks: SuperBlocks[], blockStructureDir: string)

Source from the content-addressed store, hash-verified

362}
363
364function validateBlocks(superblocks: SuperBlocks[], blockStructureDir: string) {
365 const withSuperblockStructure = addSuperblockStructure(superblocks, true);
366 const blockInSuperblocks = withSuperblockStructure
367 .flatMap(({ blocks }) => blocks)
368 .map(b => b.dashedName);
369 for (const block of blockInSuperblocks) {
370 const blockPath = getBlockStructurePath(block);
371 if (!existsSync(blockPath)) {
372 throw Error(
373 `Block "${block}" is in a superblock, but has no block structure file at ${blockPath}`
374 );
375 }
376 }
377
378 const blockStructureFiles = readdirSync(blockStructureDir).map(file =>
379 basename(file, '.json')
380 );
381
382 for (const block of blockStructureFiles) {
383 if (!blockInSuperblocks.includes(block)) {
384 throw Error(
385 `Block "${block}" has a structure file, ${getBlockStructurePath(block)}, but is not in a superblock`
386 );
387 }
388 }
389}
390
391export async function parseCurriculumStructure(filter?: Filter) {
392 const curriculum = getCurriculumStructure();

Callers 1

parseCurriculumStructureFunction · 0.85

Calls 2

addSuperblockStructureFunction · 0.85
getBlockStructurePathFunction · 0.85

Tested by

no test coverage detected