From e87301e160a3820caadba634bb42a1a6d0cf3fdb Mon Sep 17 00:00:00 2001 From: bleck9999 <55853712+bleck9999@users.noreply.github.com> Date: Sat, 16 Oct 2021 11:43:14 +0100 Subject: [PATCH] gotta save those 2.9 seconds --- Makefile | 4 ++-- ts-minifier.py | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 4eadde9..1f2c8b9 100644 --- a/Makefile +++ b/Makefile @@ -113,9 +113,9 @@ $(BUILDDIR)/$(TARGET)/script/builtin.c: scripts/*.te @mkdir -p "$(@D)" @mkdir -p "$(BUILDDIR)/$(TARGET)/scripts" ifeq ($(OS),Windows_NT) - @py ts-minifier.py -d "$(BUILDDIR)/$(TARGET)/scripts" $(wildcard scripts/*.te) + @py ts-minifier.py --such-meme -d "$(BUILDDIR)/$(TARGET)/scripts" $(wildcard scripts/*.te) @py te2c.py "$(BUILDDIR)/$(TARGET)/script/builtin" "$(BUILDDIR)/$(TARGET)/scripts" else - @python3 ts-minifier.py -d "$(BUILDDIR)/$(TARGET)/scripts" $(wildcard scripts/*.te) + @python3 ts-minifier.py --such-meme -d "$(BUILDDIR)/$(TARGET)/scripts" $(wildcard scripts/*.te) @python3 te2c.py "$(BUILDDIR)/$(TARGET)/script/builtin" "$(BUILDDIR)/$(TARGET)/scripts" endif diff --git a/ts-minifier.py b/ts-minifier.py index 47da25d..d58f04e 100644 --- a/ts-minifier.py +++ b/ts-minifier.py @@ -427,6 +427,8 @@ if __name__ == '__main__': "and attempt to generate shorter names for reused variables \ndefault: false") argparser.add_argument("-v", action="store_true", default=False, help="prints even more information to the console than usual") + argparser.add_argument("--such-meme", action="store_true", default=False, + help="replaces destination file if it already exists \ndefault: false") args = argparser.parse_args() files = args.source @@ -448,7 +450,7 @@ if __name__ == '__main__': logging.info("Stripping whitespace (pass 2)") r = whitespacent(r) file = path.splitext(path.basename(file))[0] - if path.exists(path.join(dest, f"{file}.te")): + if path.exists(path.join(dest, f"{file}.te")) and not args.such_meme: f = open(path.join(dest, f"{file}_min.te"), 'w') else: f = open(path.join(dest, f"{file}.te"), 'w')