-
Notifications
You must be signed in to change notification settings - Fork 2
/
builder.py
36 lines (24 loc) · 928 Bytes
/
builder.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
import base64
import argparse
parser = argparse.ArgumentParser(description="Compile a bat file to a js file")
parser.add_argument("-y", "--yes", help="Hide Console", action="store_true")
args = parser.parse_args()
print(args.yes)
_cwd = os.getcwd()
file_path = input("Enter the bat file path: ")
if not os.path.exists(file_path):
print("File not found")
exit()
with open(file_path, "r", encoding="utf-8", errors="ignore") as file:
bat_file = base64.b64encode(file.read().encode("utf8")).decode("utf-8")
with open(f"{_cwd}/src/to_compile/static/template.js", "r") as file:
template1 = file.read()
with open(
f"{_cwd}/src/to_compile/template.js", "w", encoding="utf8", errors="ignore"
) as file:
output = template1.replace("BASE64ENCODEDSTUFFHERE", bat_file)
if args.yes:
output = output.replace("const hide = false;", "const hide = true;")
file.write(output)
exit(0)