fix(client): handle challenge creation (#42272)

This lets us create new challenges/steps without having to restart the
client
This commit is contained in:
Oliver Eyton-Williams
2021-06-28 10:08:11 +02:00
committed by GitHub
parent 052173e502
commit 1db9a123ae
2 changed files with 56 additions and 1 deletions

View File

@@ -1,4 +1,5 @@
const _ = require('lodash');
const path = require('path');
const {
getChallengesForLang,
@@ -14,7 +15,21 @@ exports.localeChallengesRootDir = getChallengesDirForLang(curriculumLocale);
exports.replaceChallengeNode = () => {
return async function replaceChallengeNode(filePath) {
return await createChallenge(challengesDir, filePath, curriculumLocale);
// get the meta so that challengeOrder is accurate
const blockNameRe = /\d\d-[-\w]+\/([^/]+)\//;
const blockName = filePath.match(blockNameRe)[1];
const metaPath = path.resolve(
__dirname,
`../../curriculum/challenges/_meta/${blockName}/meta.json`
);
delete require.cache[require.resolve(metaPath)];
const meta = require(metaPath);
return await createChallenge(
challengesDir,
filePath,
curriculumLocale,
meta
);
};
};