-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaggregator_js.py
26 lines (20 loc) · 1 KB
/
aggregator_js.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
import os
def aggregate_js_files(startpath):
excluded_folders = {'node_modules', '.git'}
output_file = "aggregated_js_files.txt"
with open(output_file, "w") as outfile:
for root, dirs, files in os.walk(startpath):
if any(excluded_folder in root for excluded_folder in excluded_folders):
continue
dirs[:] = [d for d in dirs if d not in excluded_folders]
for file in files:
if file.endswith(".js"):
file_path = os.path.join(root, file)
relative_path = os.path.relpath(file_path, startpath)
with open(file_path, "r") as infile:
outfile.write(f"File: {relative_path}\n")
outfile.write("=" * 20 + "\n")
outfile.write(infile.read())
outfile.write("\n" + "=" * 20 + "\n\n")
if __name__ == "__main__":
aggregate_js_files(os.getcwd())