feat(tools): remove deleted challenges from i18n (#53215)

This commit is contained in:
Mama Naomi
2024-01-18 23:41:41 -08:00
committed by GitHub
parent 6c7ab615f4
commit b2568ad97b
+14 -2
View File
@@ -16,7 +16,7 @@ const loadDirectory = async (path: string): Promise<string[]> => {
} else {
files.push(path);
}
return files;
return files.filter(f => !f.includes('DS_Store'));
};
const syncChallenges = async () => {
@@ -32,7 +32,6 @@ const syncChallenges = async () => {
// we swallow the error here to detect if the file doesn't exist
const status = await stat(targetPath).catch(() => null);
if (!status) {
console.table({ path, targetPath });
const targetDir = targetPath.split(sep);
targetDir.pop();
console.log(`Syncing ${path.split('/english/')[1]}`);
@@ -42,6 +41,19 @@ const syncChallenges = async () => {
}
}
}
for (const lang of filtered) {
const langPath = join(process.cwd(), 'curriculum', 'challenges', lang);
const langFiles = await loadDirectory(langPath);
for (const path of langFiles) {
const engPath = path.replace(lang, 'english');
// we don't want an error, only need to know that the file exists
const existsEnglish = await stat(engPath).catch(() => null);
if (!existsEnglish) {
console.log(`Unlinking ${path.split(`/${lang}/`)[1]}`);
await asyncExec(`rm ${path}`);
}
}
}
};
void (async () => {