Spaces:
Runtime error
Runtime error
File size: 569 Bytes
fa66670 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import os
for root, dirs, files in os.walk("server/src/"):
for file in files:
if file.endswith(".ts"):
file_path = os.path.join(root, file)
with open(file_path, "r") as f:
content = f.read()
depth = file_path.count(os.sep) - 1 # depth from server/src
rel_path = ("../" * depth) + "types/express.d.ts"
import_str = f'import "{rel_path}";\n'
if import_str not in content:
with open(file_path, "w") as f:
f.write(import_str + content)
|