Skip to content

Commit

Permalink
refactor: use promises
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh-Cena committed Apr 17, 2022
1 parent 1d8310e commit c39411b
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,24 @@ jest.setTimeout(15000);
describe('theme translations', () => {
it('has base messages files contain EXACTLY all the translations extracted from the theme. Please run "yarn workspace @docusaurus/theme-translations update" to keep base messages files up-to-date', async () => {
const baseMessagesDirPath = path.join(__dirname, '../base');
const baseMessages = Object.fromEntries(
await Promise.all(
(
await fs.readdir(baseMessagesDirPath)
).map(async (baseMessagesFile) =>
Object.entries(
(await fs.readJSON(
path.join(baseMessagesDirPath, baseMessagesFile),
)) as {[key: string]: string},
const baseMessages = await fs
.readdir(baseMessagesDirPath)
.then((files) =>
Promise.all(
files.map(
(baseMessagesFile): Promise<{[key: string]: string}> =>
fs.readJSON(path.join(baseMessagesDirPath, baseMessagesFile)),
),
),
).then((translations) =>
translations.flat().filter(([key]) => !key.endsWith('___DESCRIPTION')),
),
);
)
.then((translations) =>
Object.fromEntries(
translations
.map(Object.entries)
.flat()
.filter(([key]) => !key.endsWith('___DESCRIPTION')),
),
);
const codeMessages = _.mapValues(
await extractThemeCodeMessages(),
(translation) => translation.message,
Expand Down

0 comments on commit c39411b

Please sign in to comment.