From b2568ad97b908e44ffe5edd99851b6fa85ec7c04 Mon Sep 17 00:00:00 2001 From: Mama Naomi Date: Thu, 18 Jan 2024 23:41:41 -0800 Subject: [PATCH] feat(tools): remove deleted challenges from i18n (#53215) --- tools/scripts/sync-i18n.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tools/scripts/sync-i18n.ts b/tools/scripts/sync-i18n.ts index 161f7787eab..1adac1c9983 100644 --- a/tools/scripts/sync-i18n.ts +++ b/tools/scripts/sync-i18n.ts @@ -16,7 +16,7 @@ const loadDirectory = async (path: string): Promise => { } 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 () => {