jprichardson / node-fs-extra

Node.js: extra methods for the fs object like copy(), remove(), mkdirs()
MIT License
9.43k stars 775 forks source link

Feature request: emptyDir() - exclude files/folders from being deleted #1015

Closed JorensM closed 11 months ago

JorensM commented 11 months ago

Hello, I have a use case where I want to empty a folder, but keep some of the files/folders in that folder if they exist.

If you're curious about my use case - I have a function that initializes a new node project in a specified directory and then runs npm install. If that directory already has a node_modules folder, I would like to keep the folder so that the node modules wouldn't need to be unnecessarily re-installed when running npm install

Thanks!

P.S I can make a PR for this too, but I would first like to know if this is something that the owners of the package would approve of.

RyanZim commented 11 months ago

If I'm understanding you correctly, I think this is basically a dupe of https://github.com/jprichardson/node-fs-extra/issues/527.