Create directory recursively.
It works similar to the mkdir -p. For Node >= 10.12.0, it will use the built-in mkdir recursive option.
$ npm install create-dirconst createDir = require("create-dir");
(async () => {
try {
await createDir("foo/bar/baz");
} catch(error) {
console.error(error.message);
}
})();createDir(path, [mode])path(String): The path directory to create.mode(optionalNumber): Directory permission, default to0o777.
It returns a Promise which when resolved contains a true value.
- write-to-file: Module to write data to file and automatically create its directories if not exists.