Spaces:
Runtime error
Runtime error
| 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) | |