Search code examples
node.jsfs-extra

Can Fs-Extra delete only files in a directory?


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

Solution

  • 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