Skip to content

Commit 00723e3

Browse files
authored
fix: generate playground should skip questions with missing locale (type-challenges#28300)
1 parent 89d8c94 commit 00723e3

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scripts/generate-play.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,17 @@ async function generatePlayground() {
149149
const { difficulty, title } = resolveInfo(quiz, locale) as QuizMetaInfo & { difficulty: string }
150150
const code = formatToCode(quiz, locale)
151151

152+
if (difficulty === undefined || title === undefined) {
153+
console.log(c.yellow(`${quiz.no} has no ${locale.toUpperCase()} version. Skipping`))
154+
continue
155+
}
156+
152157
const quizesPathByDifficulty = path.join(playgroundPath, difficulty)
153158

154159
const quizFileName = `${getQuestionFullName(quiz.no, difficulty, title)}.ts`
155160
const quizPathFull = path.join(quizesPathByDifficulty, quizFileName)
156161

157-
if (!keepChanges || (keepChanges && isQuizWritable(quizPathFull, overridableFiles!, playgroundSnapshot!))) {
162+
if (!keepChanges || (keepChanges && isQuizWritable(quizFileName, overridableFiles!, playgroundSnapshot!))) {
158163
if (!fs.existsSync(quizesPathByDifficulty))
159164
fs.mkdirSync(quizesPathByDifficulty)
160165
await fs.writeFile(quizPathFull, code, 'utf-8')

0 commit comments

Comments
 (0)