fix: handle the sorting of transformed files (#44724)
* fix: handle the sorting of transformed files We can't use the ext property, since that is transformed, but the history is maintained. * test: make solutions polyVinyls for sorting * refactor: inline prepareChallenge * refactor: make solutions polys in getChallenges * fix: convert each solution to a poly * fix: skip empty solutions * fix: get challenge file history in client * refactor: stop calling isPoly from the client * fix: remove debug console.log * refactor: remove unnecessary sorting step
This commit is contained in:
committed by
GitHub
parent
b1fb6adc39
commit
cacc4eacd7
@ -337,27 +337,29 @@ ${getFullPath('english')}
|
||||
challenge.translationPending =
|
||||
lang !== 'english' && !isAuditedCert(lang, superBlock);
|
||||
challenge.usesMultifileEditor = !!usesMultifileEditor;
|
||||
if (challenge.challengeFiles) {
|
||||
// The client expects the challengeFiles to be an array of polyvinyls
|
||||
challenge.challengeFiles = challengeFilesToPolys(challenge.challengeFiles);
|
||||
}
|
||||
if (challenge.solutions?.length) {
|
||||
// The test runner needs the solutions to be arrays of polyvinyls so it
|
||||
// can sort them correctly.
|
||||
challenge.solutions = challenge.solutions.map(challengeFilesToPolys);
|
||||
}
|
||||
|
||||
return prepareChallenge(challenge);
|
||||
return challenge;
|
||||
}
|
||||
|
||||
// gets the challenge ready for sourcing into Gatsby
|
||||
function prepareChallenge(challenge) {
|
||||
if (challenge.challengeFiles) {
|
||||
challenge.challengeFiles = challenge.challengeFiles.reduce(
|
||||
(challengeFiles, challengeFile) => {
|
||||
return [
|
||||
...challengeFiles,
|
||||
{
|
||||
...createPoly(challengeFile),
|
||||
seed: challengeFile.contents.slice(0)
|
||||
}
|
||||
];
|
||||
},
|
||||
[]
|
||||
);
|
||||
}
|
||||
return challenge;
|
||||
function challengeFilesToPolys(files) {
|
||||
return files.reduce((challengeFiles, challengeFile) => {
|
||||
return [
|
||||
...challengeFiles,
|
||||
{
|
||||
...createPoly(challengeFile),
|
||||
seed: challengeFile.contents.slice(0)
|
||||
}
|
||||
];
|
||||
}, []);
|
||||
}
|
||||
|
||||
async function hasEnglishSource(basePath, translationPath) {
|
||||
|
Reference in New Issue
Block a user