Skip to content

Commit

Permalink
πŸ› Generate file if it doesn't exist
Browse files Browse the repository at this point in the history
Signed-off-by: Bjorn Lammers <[email protected]>
  • Loading branch information
walkxcode authored Oct 20, 2024
1 parent 478994e commit 16a4a8f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion config/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ def generate_combined_tree(paths):
print("Please provide at least one folder path.")
sys.exit(1)

# Check if 'tree.json' exists
if os.path.exists('tree.json'):
print("'tree.json' already exists. No file was created.")
sys.exit(0)

# Generate the combined folder tree for all specified paths
combined_folder_tree = generate_combined_tree(folder_paths)

# Write the combined JSON structure to a file named tree.json
with open('tree.json', 'w') as f:
json.dump(combined_folder_tree, f, indent=4)

print("Folder tree successfully written to 'tree.json'.")
print("Folder tree successfully written to 'tree.json'.")

0 comments on commit 16a4a8f

Please sign in to comment.