-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.py
More file actions
54 lines (46 loc) · 1.88 KB
/
Copy pathbuild.py
File metadata and controls
54 lines (46 loc) · 1.88 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import os
from jsmin import jsmin
src_directory = 'src'
output_file = 'GE.js'
excluded_files = []
glitch_engine_file = 'GlitchEngine.js'
load_order = [
'../runtimeInject.js',
"utils.js",
'keyBehaviour/keyBehaviour.js',
'objectWindows/CanvasWindow.js',
'objectWindows/GraphicWindow.js',
'objectWindows/TextWindow.js',
'LaunchHook.js',
]
def read_and_merge_files(src_directory, excluded_files, output_file, glitch_engine_file, load_order):
merged_content = []
for file in load_order:
if file in excluded_files:
continue
file_path = os.path.join(src_directory, file)
if os.path.exists(file_path):
with open(file_path, 'r') as f:
lines = f.readlines()
filtered_lines = [line for line in lines if not (line.strip().startswith('import') or line.strip().startswith('export'))]
merged_content.extend(filtered_lines)
# Add the last line of GlitchEngine.js to the merged content
if os.path.exists(glitch_engine_file):
with open(glitch_engine_file, 'r') as f:
lines = f.readlines()
if lines:
last_line = lines[-1]
merged_content.append("\nruntimeInject.inject();\n"+last_line) # This is super cool and stable
# Ensure the output file is created if it doesn't exist
if not os.path.exists(output_file):
open(output_file, 'w').close()
with open(output_file, 'w') as f:
f.writelines(merged_content)
# Perform jsmin operation and save to new file
minified_output_file = output_file.replace('.js', '.min.js')
with open(output_file, 'r') as f:
minified_content = jsmin(f.read())
with open(minified_output_file, 'w') as f:
f.write(minified_content)
if __name__ == "__main__":
read_and_merge_files(src_directory, excluded_files, output_file, glitch_engine_file, load_order)