| 1 |
|
| 2 |
|
| 3 |
import glob |
| 4 |
import os |
| 5 |
import sys |
| 6 |
|
| 7 |
if len(sys.argv) < 2: |
| 8 |
print("Invalid usage of dotnet_format.py, it should be called with a path to one or multiple files.") |
| 9 |
sys.exit(1) |
| 10 |
|
| 11 |
|
| 12 |
for path in [ |
| 13 |
"modules/mono/SdkPackageVersions.props", |
| 14 |
]: |
| 15 |
if os.path.exists(path): |
| 16 |
continue |
| 17 |
os.makedirs(os.path.dirname(path), exist_ok=True) |
| 18 |
with open(path, "w", encoding="utf-8", newline="\n") as f: |
| 19 |
f.write("<Project />") |
| 20 |
|
| 21 |
|
| 22 |
os.environ["GodotSkipGenerated"] = "true" |
| 23 |
|
| 24 |
|
| 25 |
projects = { |
| 26 |
path: " ".join([f for f in sys.argv[1:] if os.path.commonpath([f, path]) == path]) |
| 27 |
for path in [os.path.dirname(f) for f in glob.glob("**/*.csproj", recursive=True)] |
| 28 |
} |
| 29 |
|
| 30 |
|
| 31 |
for path, files in projects.items(): |
| 32 |
if files: |
| 33 |
os.system(f"dotnet format {path} --include {files}") |