fix(tools): wait for the last challenge to be populated (#35596)
This commit is contained in:
committed by
Oliver Eyton-Williams
parent
322134031a
commit
4d79af2b46
@ -18,11 +18,20 @@ exports.getChallengesDirForLang = getChallengesDirForLang;
|
||||
|
||||
exports.getChallengesForLang = function getChallengesForLang(lang) {
|
||||
let curriculum = {};
|
||||
return new Promise(resolve =>
|
||||
return new Promise(resolve => {
|
||||
let running = 1;
|
||||
function done() {
|
||||
if (--running === 0) {
|
||||
resolve(curriculum);
|
||||
}
|
||||
}
|
||||
readDirP({ root: getChallengesDirForLang(lang) })
|
||||
.on('data', file => buildCurriculum(file, curriculum))
|
||||
.on('end', () => resolve(curriculum))
|
||||
);
|
||||
.on('data', file => {
|
||||
running++;
|
||||
buildCurriculum(file, curriculum).then(done);
|
||||
})
|
||||
.on('end', done);
|
||||
});
|
||||
};
|
||||
|
||||
async function buildCurriculum(file, curriculum) {
|
||||
|
Reference in New Issue
Block a user