-
Notifications
You must be signed in to change notification settings - Fork 772
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
Feature request: isEmptyDir() #1037
Comments
This is basically a duplicate of #420; though I'm open to reconsidering the decision there. Can you elaborate more on the use-case here? |
Oh, sorry, I didn't notice this.
For example, in pnpm, there is a There is also scaffolding that when initializing a project, it will also judge whether it is empty to decide whether to overwrite the content and continue or cancel. And I think this method can also be reused internally in |
I'm especially hesitant to add it as it's trivial to implement wherever it's needed; the code is literally: !(await fs.readdir(dir)).length Is it worth creating a method just for this? |
Also, in the case of something like |
Yes, the code implementation seems relatively simple.
It is hoped that providing this wrapper function is just a suggestion. It is difficult for me to give a strong support for whether it is worth adding. The scenario I am currently encountering is the example I provided above. |
cc @JPeer264 @manidlou @jprichardson for thoughts |
@RyanZim I have some thoughts.
|
@SukkaW That's an interesting point; in that case I'd be open to a PR adding it. |
I can create a PR adding it! |
Sometimes we encounter situations where we need to determine whether a directory is empty before deleting or performing other operations. Therefore, I think it might be convenient if an API can be provided.
The text was updated successfully, but these errors were encountered: