fix: errors if challenge file needs renaming (#54130)

This commit is contained in:
Oliver Eyton-Williams
2024-03-18 16:29:11 +01:00
committed by GitHub
parent a218be17b3
commit a6140777a5
2 changed files with 23 additions and 2 deletions
@@ -130,7 +130,14 @@ dashedName: step-3
process.env.CALLING_DIR = projectPath;
expect(() => validateMetaData()).toThrow(
`ENOENT: no such file or directory, access '${projectPath}/1.md'`
`The file
${projectPath}/1.md
does not exist, but is required by the challengeOrder of
${metaPath}/meta.json
To fix this, you can rename the file containing id: 1 to 1.md
If there is no file for this id, then either the challengeOrder needs to be updated, or the file needs to be created.
`
);
});
@@ -44,7 +44,21 @@ function validateMetaData(): void {
// each step in the challengeOrder should correspond to a file
challengeOrder.forEach(({ id }) => {
fs.accessSync(`${getProjectPath()}${id}.md`);
const filePath = `${getProjectPath()}${id}.md`;
try {
fs.accessSync(filePath);
} catch (e) {
throw new Error(
`The file
${filePath}
does not exist, but is required by the challengeOrder of
${getProjectMetaPath()}
To fix this, you can rename the file containing id: ${id} to ${id}.md
If there is no file for this id, then either the challengeOrder needs to be updated, or the file needs to be created.
`
);
}
});
// each file should have a corresponding step in the challengeOrder