diff options
author | João Moreno <joao.moreno@microsoft.com> | 2022-07-08 07:03:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-08 07:03:08 +0300 |
commit | 274aed07cc6fa04dc99984d3ee90f45d3711a7df (patch) | |
tree | 52513124140efd53346c74f14f5cf54375f4be1e /build/lib/policies.ts | |
parent | 8885bda5e7b3c61004ce6af05f074f89615fb4fc (diff) |
policies: skip languages which do not exist (#154395)
Diffstat (limited to 'build/lib/policies.ts')
-rw-r--r-- | build/lib/policies.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/build/lib/policies.ts b/build/lib/policies.ts index 62ea4d561e5..f56aec1a6a9 100644 --- a/build/lib/policies.ts +++ b/build/lib/policies.ts @@ -585,7 +585,8 @@ const Languages = { }; type LanguageTranslations = { [moduleName: string]: { [nlsKey: string]: string } }; -type Translations = { languageId: string; languageTranslations: LanguageTranslations }[]; +type Translation = { languageId: string; languageTranslations: LanguageTranslations }; +type Translations = Translation[]; async function getLatestStableVersion(updateUrl: string) { const res = await fetch(`${updateUrl}/api/update/darwin/stable/latest`); @@ -643,10 +644,15 @@ async function getTranslations(): Promise<Translations> { const version = await getLatestStableVersion(updateUrl); const languageIds = Object.keys(Languages); - return await Promise.all(languageIds.map( + const result = await Promise.allSettled(languageIds.map( languageId => getNLS(resourceUrlTemplate, languageId, version) + .catch(err => { console.warn(`Missing translation: ${languageId}@${version}`); return Promise.reject(err); }) .then(languageTranslations => ({ languageId, languageTranslations })) )); + + return result + .filter((r): r is PromiseFulfilledResult<Translation> => r.status === 'fulfilled') + .map(r => r.value); } async function main() { |