-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfix_usequery.py
More file actions
29 lines (24 loc) · 839 Bytes
/
Copy pathfix_usequery.py
File metadata and controls
29 lines (24 loc) · 839 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
import os
import re
def process_file(filepath):
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
# We want to replace:
# enabled: isAdmin,
# }, { staleTime: 30_000 });
# with:
# enabled: isAdmin,
# staleTime: 30_000
# });
# Simple regex to merge the two objects
# This looks for }, { staleTime: ... } and replaces it with , staleTime: ... }
original = content
content = re.sub(r'\}, \s*{\s*staleTime:', ', staleTime:', content)
if content != original:
with open(filepath, 'w', encoding='utf-8') as f:
f.write(content)
print(f"Updated {filepath}")
for root, dirs, files in os.walk('client/src/pages'):
for file in files:
if file.endswith('.tsx'):
process_file(os.path.join(root, file))