To use the mkdirp
function from fs-extra
, you first need to install fs-extra
by running npm install fs-extra
.
Once installed, you can require the fs-extra
module:
index.tsx32 chars2 lines
Then, you can use the mkdirp
function to create a directory and any necessary parent directories if they do not exist:
index.tsx139 chars8 lines
The mkdirp
function returns a promise, so you can use .then()
and .catch()
to handle success and errors respectively.
If the directory already exists, the mkdirp
function will not throw an error and the promise will resolve immediately.
index.tsx166 chars8 lines
gistlibby LogSnag