https://github.com/risan/create-dir
Create directory recursively.
https://github.com/risan/create-dir
fs mkdir mkdirp recursive
Last synced: 5 months ago
JSON representation
Create directory recursively.
- Host: GitHub
- URL: https://github.com/risan/create-dir
- Owner: risan
- License: mit
- Created: 2018-11-28T03:24:13.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-25T13:21:54.000Z (over 6 years ago)
- Last Synced: 2025-11-23T23:12:45.583Z (7 months ago)
- Topics: fs, mkdir, mkdirp, recursive
- Language: JavaScript
- Homepage:
- Size: 36.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Create Directory Recursively
[](https://travis-ci.org/risan/create-dir)
[](https://codecov.io/gh/risan/create-dir)
[](https://www.npmjs.com/package/create-dir)
Create directory recursively.
It works similar to the `mkdir -p`. For Node `>= 10.12.0`, it will use the built-in `mkdir` `recursive` option.
## Installation
```bash
$ npm install create-dir
```
## Usage
```js
const createDir = require("create-dir");
(async () => {
try {
await createDir("foo/bar/baz");
} catch(error) {
console.error(error.message);
}
})();
```
## API
```js
createDir(path, [mode])
```
### Parameters
* `path` (`String`): The path directory to create.
* `mode` (optional `Number`): Directory permission, default to `0o777`.
### Returns
It returns a `Promise` which when resolved contains a `true` value.
## Related
* [write-to-file](https://github.com/risan/write-to-file): Module to write data to file and automatically create its directories if not exists.
## License
[MIT](https://github.com/risan/create-dir/blob/master/LICENSE) © [Risan Bagja Pradana](https://bagja.net)