forked from dyad-sh/dyad
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclear_console_logs.py
More file actions
30 lines (23 loc) · 1009 Bytes
/
clear_console_logs.py
File metadata and controls
30 lines (23 loc) · 1009 Bytes
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
import re
import os
def remove_console_logs_from_file(file_path):
# Read the contents of the file
with open(file_path, 'r') as file:
content = file.read()
# Regular expression to match console.log statements
pattern = r'console\.log\(.*?\);?'
# Remove all console.log statements
modified_content = re.sub(pattern, '', content)
# Write the modified content back to the file
with open(file_path, 'w') as file:
file.write(modified_content)
print(f"Removed all console.log statements from {file_path}")
def remove_console_logs_from_directory(directory):
for root, _, files in os.walk(directory):
for file in files:
if file.endswith('.ts') or file.endswith(".tsx"):
file_path = os.path.join(root, file)
remove_console_logs_from_file(file_path)
if __name__ == "__main__":
src_directory = 'src' # Change this to the path of your src directory
remove_console_logs_from_directory(src_directory)