fix(curriculum): validate straight after parsing (#38896)
This commit is contained in:
committed by
GitHub
parent
db08ab2965
commit
4d176bf2fb
@ -81,17 +81,12 @@ async function buildCurriculum(file, curriculum, validate) {
|
|||||||
}
|
}
|
||||||
const { meta } = challengeBlock;
|
const { meta } = challengeBlock;
|
||||||
|
|
||||||
const challenge = await createChallenge(fullPath, meta);
|
const challenge = await createChallenge(fullPath, meta, validate);
|
||||||
|
|
||||||
const result = validate(challenge);
|
|
||||||
if (result.error) {
|
|
||||||
console.log(result.value);
|
|
||||||
throw new Error(result.error);
|
|
||||||
}
|
|
||||||
challengeBlock.challenges = [...challengeBlock.challenges, challenge];
|
challengeBlock.challenges = [...challengeBlock.challenges, challenge];
|
||||||
}
|
}
|
||||||
|
|
||||||
async function createChallenge(fullPath, maybeMeta) {
|
async function createChallenge(fullPath, maybeMeta, validate) {
|
||||||
let meta;
|
let meta;
|
||||||
if (maybeMeta) {
|
if (maybeMeta) {
|
||||||
meta = maybeMeta;
|
meta = maybeMeta;
|
||||||
@ -104,6 +99,11 @@ async function createChallenge(fullPath, maybeMeta) {
|
|||||||
}
|
}
|
||||||
const { name: superBlock } = superBlockInfoFromFullPath(fullPath);
|
const { name: superBlock } = superBlockInfoFromFullPath(fullPath);
|
||||||
const challenge = await parseMarkdown(fullPath);
|
const challenge = await parseMarkdown(fullPath);
|
||||||
|
const result = validate(challenge);
|
||||||
|
if (result.error) {
|
||||||
|
console.log(result.value);
|
||||||
|
throw new Error(result.error);
|
||||||
|
}
|
||||||
const challengeOrder = findIndex(
|
const challengeOrder = findIndex(
|
||||||
meta.challengeOrder,
|
meta.challengeOrder,
|
||||||
([id]) => id === challenge.id
|
([id]) => id === challenge.id
|
||||||
|
Reference in New Issue
Block a user