source: trip-planner-front/node_modules/make-dir/readme.md

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.1 KB
Line 
1# make-dir [![Build Status](https://travis-ci.org/sindresorhus/make-dir.svg?branch=master)](https://travis-ci.org/sindresorhus/make-dir) [![codecov](https://codecov.io/gh/sindresorhus/make-dir/branch/master/graph/badge.svg)](https://codecov.io/gh/sindresorhus/make-dir)
2
3> Make a directory and its parents if needed - Think `mkdir -p`
4
5## Advantages over [`mkdirp`](https://github.com/substack/node-mkdirp)
6
7- Promise API *(Async/await ready!)*
8- Fixes many `mkdirp` issues: [#96](https://github.com/substack/node-mkdirp/pull/96) [#70](https://github.com/substack/node-mkdirp/issues/70) [#66](https://github.com/substack/node-mkdirp/issues/66)
9- 100% test coverage
10- CI-tested on macOS, Linux, and Windows
11- Actively maintained
12- Doesn't bundle a CLI
13- Uses the native `fs.mkdir/mkdirSync` [`recursive` option](https://nodejs.org/dist/latest/docs/api/fs.html#fs_fs_mkdir_path_options_callback) in Node.js >=10.12.0 unless [overridden](#fs)
14
15## Install
16
17```
18$ npm install make-dir
19```
20
21## Usage
22
23```
24$ pwd
25/Users/sindresorhus/fun
26$ tree
27.
28```
29
30```js
31const makeDir = require('make-dir');
32
33(async () => {
34 const path = await makeDir('unicorn/rainbow/cake');
35
36 console.log(path);
37 //=> '/Users/sindresorhus/fun/unicorn/rainbow/cake'
38})();
39```
40
41```
42$ tree
43.
44└── unicorn
45 └── rainbow
46 └── cake
47```
48
49Multiple directories:
50
51```js
52const makeDir = require('make-dir');
53
54(async () => {
55 const paths = await Promise.all([
56 makeDir('unicorn/rainbow'),
57 makeDir('foo/bar')
58 ]);
59
60 console.log(paths);
61 /*
62 [
63 '/Users/sindresorhus/fun/unicorn/rainbow',
64 '/Users/sindresorhus/fun/foo/bar'
65 ]
66 */
67})();
68```
69
70## API
71
72### makeDir(path, options?)
73
74Returns a `Promise` for the path to the created directory.
75
76### makeDir.sync(path, options?)
77
78Returns the path to the created directory.
79
80#### path
81
82Type: `string`
83
84Directory to create.
85
86#### options
87
88Type: `object`
89
90##### mode
91
92Type: `integer`\
93Default: `0o777`
94
95Directory [permissions](https://x-team.com/blog/file-system-permissions-umask-node-js/).
96
97##### fs
98
99Type: `object`\
100Default: `require('fs')`
101
102Use a custom `fs` implementation. For example [`graceful-fs`](https://github.com/isaacs/node-graceful-fs).
103
104Using a custom `fs` implementation will block the use of the native `recursive` option if `fs.mkdir` or `fs.mkdirSync` is not the native function.
105
106## Related
107
108- [make-dir-cli](https://github.com/sindresorhus/make-dir-cli) - CLI for this module
109- [del](https://github.com/sindresorhus/del) - Delete files and directories
110- [globby](https://github.com/sindresorhus/globby) - User-friendly glob matching
111- [cpy](https://github.com/sindresorhus/cpy) - Copy files
112- [cpy-cli](https://github.com/sindresorhus/cpy-cli) - Copy files on the command-line
113- [move-file](https://github.com/sindresorhus/move-file) - Move a file
114
115---
116
117<div align="center">
118 <b>
119 <a href="https://tidelift.com/subscription/pkg/npm-make-dir?utm_source=npm-make-dir&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
120 </b>
121 <br>
122 <sub>
123 Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
124 </sub>
125</div>
Note: See TracBrowser for help on using the repository browser.