mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-11-09 13:41:45 +00:00
thanks DeltaV
This commit is contained in:
parent
13d320a355
commit
80d6ad6a00
1 changed files with 8 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
# Copyright (c) 2021 bleck9999
|
# Copyright (c) 2021 bleck9999
|
||||||
# https://github.com/bleck9999/ts-minifier
|
# https://github.com/bleck9999/ts-minifier
|
||||||
# Version: 9d56e91a
|
# Version: 339183b2
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import itertools
|
import itertools
|
||||||
|
@ -421,7 +421,7 @@ if __name__ == '__main__':
|
||||||
formatter_class=argparse.RawTextHelpFormatter)
|
formatter_class=argparse.RawTextHelpFormatter)
|
||||||
argparser.add_argument("source", type=str, nargs='+', help="source files to minify")
|
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"
|
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,
|
argparser.add_argument("--auto-replace", action="store_true", default=False,
|
||||||
help="automatically replace reused functions, variables and strings instead of just warning\n"
|
help="automatically replace reused functions, variables and strings instead of just warning\n"
|
||||||
"and attempt to generate shorter names for reused variables \ndefault: false")
|
"and attempt to generate shorter names for reused variables \ndefault: false")
|
||||||
|
@ -430,7 +430,7 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
args = argparser.parse_args()
|
args = argparser.parse_args()
|
||||||
files = args.source
|
files = args.source
|
||||||
dest = args.d[:-1] if args.d[-1] in '/\\' else args.d
|
dest = args.d
|
||||||
auto_replace = args.auto_replace
|
auto_replace = args.auto_replace
|
||||||
verbose = "INFO" if args.v else "WARNING"
|
verbose = "INFO" if args.v else "WARNING"
|
||||||
logging.basicConfig(level=verbose, format="{message}", style='{')
|
logging.basicConfig(level=verbose, format="{message}", style='{')
|
||||||
|
@ -447,11 +447,12 @@ if __name__ == '__main__':
|
||||||
r = minify(r[0], r[1], r[2])
|
r = minify(r[0], r[1], r[2])
|
||||||
logging.info("Stripping whitespace (pass 2)")
|
logging.info("Stripping whitespace (pass 2)")
|
||||||
r = whitespacent(r)
|
r = whitespacent(r)
|
||||||
file = file.split(sep='.')[0].split(sep='/')[-1]
|
file = path.splitext(path.basename(file))[0]
|
||||||
if path.exists(f"{dest}/{file}.te"):
|
if path.exists(path.join(dest, f"{file}.te")):
|
||||||
f = open(f"{dest}/{file}_min.te", 'w')
|
f = open(path.join(dest, f"{file}_min.te"), 'w')
|
||||||
else:
|
else:
|
||||||
f = open(f"{dest}/{file}.te", 'w')
|
f = open(path.join(dest, f"{file}.te"), 'w')
|
||||||
logging.info(f"Writing to {f.name}")
|
logging.info(f"Writing to {f.name}")
|
||||||
f.write(r)
|
f.write(r)
|
||||||
print("Done!")
|
print("Done!")
|
||||||
|
f.close()
|
||||||
|
|
Loading…
Reference in a new issue