Here is an example of how to use the mkdirpSync
function from the fs-extra
package to make sure that a directory exists:
index.tsx118 chars8 lines
The mkdirpSync
function will create the directory at /path/to/directory
, including any necessary parent directories. If the directory already exists, it will not be modified in any way.
Note that the mkdirpSync
function is synchronous, which means that it will block the event loop until the directory has been created. If you need to create directories asynchronously, you can use the mkdirp
function instead.
gistlibby LogSnag