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

Directory - Ability to delete all children #763

Closed
dsherret opened this issue Nov 24, 2019 · 0 comments
Closed

Directory - Ability to delete all children #763

dsherret opened this issue Nov 24, 2019 · 0 comments

Comments

@dsherret
Copy link
Owner

dsherret commented Nov 24, 2019

Would be nice to be able to delete a directory and recreate it without losing the reference to the directory.

Pain Point

const myDir = project.getDirectoryOrThrow("my-dir");
myDir.delete();
myDir.createSourceFile(...); // error since myDir was forgotten :(

Solution?

Something like delete(), but it won't forget the directory reference and will queue a mkdir immediately after.

const myDir = project.getDirectoryOrThrow("my-dir");
myDir.recreate();
myDir.createSourceFile(...); // ok

Probably would have a name like recreate() or deleteDescendants().

Edit: I went with .clear().

@dsherret dsherret added this to the Version Next milestone Nov 24, 2019
dsherret added a commit that referenced this issue Nov 24, 2019
@dsherret dsherret modified the milestones: Version Next, Version 6 Nov 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant