From f44c96edafeba83bcbb73584fbb9653020523ed8 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 19 May 2025 11:54:47 -0400 Subject: [PATCH] no need for this to be async --- .../svelte/scripts/process-messages/index.js | 22 ++----------------- 1 file changed, 2 insertions(+), 20 deletions(-) diff --git a/packages/svelte/scripts/process-messages/index.js b/packages/svelte/scripts/process-messages/index.js index 838017b850..92acd9a6a9 100644 --- a/packages/svelte/scripts/process-messages/index.js +++ b/packages/svelte/scripts/process-messages/index.js @@ -11,12 +11,7 @@ const [, , watch_flag] = process.argv; const watch = watch_flag === '-w'; -/** - * @type {((value?: any) => void) | undefined} - */ -let resolve_writing_promise; - -async function run() { +function run() { /** @type {Record>} */ const messages = {}; const seen = new Set(); @@ -67,18 +62,10 @@ async function run() { sorted.sort((a, b) => (a.code < b.code ? -1 : 1)); - const writing_promise = watch - ? new Promise((resolve) => { - resolve_writing_promise = resolve; - }) - : Promise.resolve(); - fs.writeFileSync( `messages/${category}/${file}`, sorted.map((x) => x._.trim()).join('\n\n') + '\n' ); - - await writing_promise; } fs.writeFileSync( @@ -435,15 +422,10 @@ async function run() { if (watch) { fs.watch('messages', { recursive: true }, () => { - if (resolve_writing_promise) { - resolve_writing_promise(); - resolve_writing_promise = undefined; - return; - } // eslint-disable-next-line no-console console.log('Regenerating messages...'); run(); }); } -await run(); +run();