To use the emptyDir
function from the fs-extra
module in Node.js, first we need to install it using npm:
index.tsx21 chars2 lines
After that, we can require it in our .js
file as shown below:
32 chars2 lines
To empty the contents of a directory using fs-extra
's emptyDir()
:
236 chars13 lines
The emptyDir
function empty the entire directory which means it removes all the files and directories inside it. It will also create the directory if it doesn't exist, so be careful while using it.
gistlibby LogSnag