-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgenerate.py
39 lines (26 loc) · 986 Bytes
/
generate.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
37
38
39
import os
import sys
from watchgod import watch
def compile():
moduleContent = ''
with open("./src/module.lua", 'r') as file:
moduleContent = file.read()
files = os.listdir('./src/textareas')
for file in files:
replaceString = f'{{{{textareas/{file}}}}}'
if not (replaceString in moduleContent):
continue
fileContent = ''
with open(f"./src/textareas/{file}") as file:
fileContent = "".join(line.rstrip() for line in file)
fileContent = fileContent.replace("\t", "").replace(' ', '')
moduleContent = moduleContent.replace(replaceString, fileContent)
with open("./dist/compiled.lua", "w") as f:
f.write(moduleContent)
compile()
print(f'Compiled successfully.')
if (len(sys.argv) > 1 and sys.argv[1] == "--watch"):
for changes in watch('./src'):
print(f'Got change {changes}, compiling...')
compile()
print(f'Compiled successfully.')