thanks DeltaV

This commit is contained in:
bleck9999 2021-09-12 16:12:06 +01:00
parent 13d320a355
commit 80d6ad6a00
No known key found for this signature in database
GPG Key ID: D0CA0C41DB616843
1 changed files with 8 additions and 7 deletions

View File

@ -1,6 +1,6 @@
# Copyright (c) 2021 bleck9999
# https://github.com/bleck9999/ts-minifier
# Version: 9d56e91a
# Version: 339183b2
import argparse
import itertools
@ -421,7 +421,7 @@ if __name__ == '__main__':
formatter_class=argparse.RawTextHelpFormatter)
argparser.add_argument("source", type=str, nargs='+', help="source files to minify")
argparser.add_argument("-d", type=str, nargs='?', help="destination folder for minified scripts"
"\ndefault: ./", default='./')
"\ndefault: .", default='.')
argparser.add_argument("--auto-replace", action="store_true", default=False,
help="automatically replace reused functions, variables and strings instead of just warning\n"
"and attempt to generate shorter names for reused variables \ndefault: false")
@ -430,7 +430,7 @@ if __name__ == '__main__':
args = argparser.parse_args()
files = args.source
dest = args.d[:-1] if args.d[-1] in '/\\' else args.d
dest = args.d
auto_replace = args.auto_replace
verbose = "INFO" if args.v else "WARNING"
logging.basicConfig(level=verbose, format="{message}", style='{')
@ -447,11 +447,12 @@ if __name__ == '__main__':
r = minify(r[0], r[1], r[2])
logging.info("Stripping whitespace (pass 2)")
r = whitespacent(r)
file = file.split(sep='.')[0].split(sep='/')[-1]
if path.exists(f"{dest}/{file}.te"):
f = open(f"{dest}/{file}_min.te", 'w')
file = path.splitext(path.basename(file))[0]
if path.exists(path.join(dest, f"{file}.te")):
f = open(path.join(dest, f"{file}_min.te"), 'w')
else:
f = open(f"{dest}/{file}.te", 'w')
f = open(path.join(dest, f"{file}.te"), 'w')
logging.info(f"Writing to {f.name}")
f.write(r)
print("Done!")
f.close()