Skip to content

Commit

Permalink
Clear generated dir before generation
Browse files Browse the repository at this point in the history
This ensures that in case of changed names/removals we don't end up with dead types that won't get removed.
  • Loading branch information
michpohl committed Oct 23, 2024
1 parent 265c7fa commit 6d2c046
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tidalapi/bin/generate-api-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import os
import requests
import shutil
import subprocess
import sys
from collections import OrderedDict
Expand Down Expand Up @@ -158,7 +159,16 @@ def main():
# Create the merged schema and get the path to the OpenAPI generator jar
temp_json, source = create_merged_schema(config_file)

logging.info(f"Project root: {project_root}")
# Define the generated files path and clean the directory
generated_files_dir = os.path.join(project_root,
"src/main/kotlin/com/tidal/sdk/tidalapi/generated")

# Clean the directory
if os.path.exists(generated_files_dir):
shutil.rmtree(generated_files_dir)
logging.info(f"Cleaned up directory: {generated_files_dir}")

os.makedirs(generated_files_dir, exist_ok=True)

result = subprocess.run([
"java", "-jar", source, "generate",
Expand Down

0 comments on commit 6d2c046

Please sign in to comment.