mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 15:47:18 +02:00
build: collapse if/else blocks without curly braces
This commit is contained in:
parent
9609d0ae7b
commit
cc422b31a4
5
build.ts
5
build.ts
@ -66,9 +66,8 @@ const postProcess = (str: string): string => {
|
|||||||
// Collapse empty brackets
|
// Collapse empty brackets
|
||||||
str = str.replaceAll(/\{[\s\n]+\}/g, '{}');
|
str = str.replaceAll(/\{[\s\n]+\}/g, '{}');
|
||||||
|
|
||||||
// Collapse single return
|
// Collapse if/else blocks without curly braces
|
||||||
str = str.replaceAll(/\)\n\s+return/g, ') return');
|
str = str.replaceAll(/((if \(.*?\)|else)\n\s+)/g, '$2 ');
|
||||||
str = str.replaceAll(/else\n\s+return/g, 'else return');
|
|
||||||
|
|
||||||
// Remove blank lines
|
// Remove blank lines
|
||||||
str = str.replaceAll(/\n([\s]*)\n/g, "\n");
|
str = str.replaceAll(/\n([\s]*)\n/g, "\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user