Can Fs-Extra delete only files in a directory?

4.8k Views Asked by At

Can I do delete all files in apples directory without deleting the directory itself? fs-extra API does not describe if it is possible.

 fsExtra.remove 'apples/*', ->
    if !err
    # Do stuff
1

There are 1 best solutions below

1
On BEST ANSWER

You can use emptyDir

Ensures that a directory is empty. If the directory does not exist, it is created. The directory itself is not deleted.

fsExtra.emptyDir 'apples/', ->
    if !err
    # Do stuff