Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cleanup generated folder #17

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: cleanup generated folder #17

wants to merge 1 commit into from

Conversation

jpudysz
Copy link
Contributor

@jpudysz jpudysz commented Aug 8, 2024

When I was experimenting with some nitrogen options, I noticed that the generated folder retains old directories and doesn't remove them when there is no spec.

This small PR ensures that the generated folder will be removed recursively whenever the user runs script. Additionally, if the user decides to remove specs and runs the script again, the folder will be empty.

Before:

Example if I try to generate code from swift / kotlin to C++
image

After:

image

Also there is a small indicator that folder has been removed:
image

@jpudysz jpudysz requested a review from mrousavy August 8, 2024 13:51
@mrousavy
Copy link
Owner

mrousavy commented Aug 8, 2024

Thanks for this PR, this is definitely fixing a bug, but I explicitly scanned the directory first, wrote the files, and only AFTERWARDS I removed all files that weren't part of the generated specs.

That way we can avoid flickers in IDEs or git tools or watchman, overwriting files is better than deleting and writing again.

But maybe I am overengineering this...
I think we cannot merge this as is, we need to remove directories the same way we remove unused files at the end of index.ts

on my phone rn so cant post line numbers

@mrousavy mrousavy added the nitrogen Issue is related to the code-generator "Nitrogen" label Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nitrogen Issue is related to the code-generator "Nitrogen"
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants