From cc422b31a48d6e8130e3fb4aedf764f14efd680f Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Wed, 25 Sep 2024 19:43:19 +0700 Subject: [PATCH] build: collapse if/else blocks without curly braces --- build.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build.ts b/build.ts index 6dc06ae..0959b05 100644 --- a/build.ts +++ b/build.ts @@ -66,9 +66,8 @@ const postProcess = (str: string): string => { // Collapse empty brackets str = str.replaceAll(/\{[\s\n]+\}/g, '{}'); - // Collapse single return - str = str.replaceAll(/\)\n\s+return/g, ') return'); - str = str.replaceAll(/else\n\s+return/g, 'else return'); + // Collapse if/else blocks without curly braces + str = str.replaceAll(/((if \(.*?\)|else)\n\s+)/g, '$2 '); // Remove blank lines str = str.replaceAll(/\n([\s]*)\n/g, "\n");