Skip to content

Commit

Permalink
fix(localization): 🚨 Fixed error that (i think) came from the i18n ge…
Browse files Browse the repository at this point in the history
…neration timing out
  • Loading branch information
Joery-M committed Nov 11, 2024
1 parent 26646ee commit e2e6a8b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/safelight/buildscripts/vite-plugin-generate-i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ interface Options {
async function compileTypes({ localesDir: dir, outputFile: output }: Options) {
const files = await glob(dir + '/*.json', {
signal: AbortSignal.timeout(1000)
}).catch((err) => {
console.error('Could not find i18n files:', err);
return [] as string[];
});
if (!files.length) return;

// Combine all files into 1 object
const allFiles: Record<string, any> = {};
Expand Down Expand Up @@ -94,7 +98,9 @@ declare module 'vue-i18n' {
outputFile = outputFile.replace(/((?<!\r)\n|\r(?!\n))/g, '\r\n');

// No need to wait for finishing writing, if it does take long, skip it
writeFile(output, outputFile, { signal: AbortSignal.timeout(100) });
writeFile(output, outputFile, { signal: AbortSignal.timeout(100) }).catch((err) =>
console.error('Error writing i18n definitions:', err)
);
}

// Source: https://stackoverflow.com/a/34749873
Expand Down

0 comments on commit e2e6a8b

Please sign in to comment.