BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / mkdirp / readme.markdown

readme.markdown

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
readme.markdown 2.0 KiB Download Raw

mkdirp

Like mkdir -p, but in node.js!

build status

example

pow.js

var mkdirp = require('mkdirp');
    
mkdirp('/tmp/foo/bar/baz', function (err) {
    if (err) console.error(err)
    else console.log('pow!')
});

Output

pow!

And now /tmp/foo/bar/baz exists, huzzah!

methods

var mkdirp = require('mkdirp');

mkdirp(dir, opts, cb)

Create a new directory and any necessary subdirectories at dir with octal permission string opts.mode. If opts is a non-object, it will be treated as the opts.mode.

If opts.mode isn't specified, it defaults to 0777 & (~process.umask()).

cb(err, made) fires with the error or the first directory made that had to be created, if any.

You can optionally pass in an alternate fs implementation by passing in opts.fs. Your implementation should have opts.fs.mkdir(path, mode, cb) and opts.fs.stat(path, cb).

mkdirp.sync(dir, opts)

Synchronously create a new directory and any necessary subdirectories at dir with octal permission string opts.mode. If opts is a non-object, it will be treated as the opts.mode.

If opts.mode isn't specified, it defaults to 0777 & (~process.umask()).

Returns the first directory that had to be created, if any.

You can optionally pass in an alternate fs implementation by passing in opts.fs. Your implementation should have opts.fs.mkdirSync(path, mode) and opts.fs.statSync(path).

usage

This package also ships with a mkdirp command.

usage: mkdirp [DIR1,DIR2..] {OPTIONS}

  Create each supplied directory including any necessary parent directories that
  don't yet exist.
  
  If the directory already exists, do nothing.

OPTIONS are:

  -m, --mode   If a directory needs to be created, set the mode as an octal
               permission string.

install

With npm do:

npm install mkdirp

to get the library, or

npm install -g mkdirp

to get the command.

license

MIT

Source
1# mkdirp
2
3Like `mkdir -p`, but in node.js!
4
5[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp)
6
7# example
8
9## pow.js
10
11```js
12var mkdirp = require('mkdirp');
13
14mkdirp('/tmp/foo/bar/baz', function (err) {
15 if (err) console.error(err)
16 else console.log('pow!')
17});
18```
19
20Output
21
22```
23pow!
24```
25
26And now /tmp/foo/bar/baz exists, huzzah!
27
28# methods
29
30```js
31var mkdirp = require('mkdirp');
32```
33
34## mkdirp(dir, opts, cb)
35
36Create a new directory and any necessary subdirectories at `dir` with octal
37permission string `opts.mode`. If `opts` is a non-object, it will be treated as
38the `opts.mode`.
39
40If `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`.
41
42`cb(err, made)` fires with the error or the first directory `made`
43that had to be created, if any.
44
45You can optionally pass in an alternate `fs` implementation by passing in
46`opts.fs`. Your implementation should have `opts.fs.mkdir(path, mode, cb)` and
47`opts.fs.stat(path, cb)`.
48
49## mkdirp.sync(dir, opts)
50
51Synchronously create a new directory and any necessary subdirectories at `dir`
52with octal permission string `opts.mode`. If `opts` is a non-object, it will be
53treated as the `opts.mode`.
54
55If `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`.
56
57Returns the first directory that had to be created, if any.
58
59You can optionally pass in an alternate `fs` implementation by passing in
60`opts.fs`. Your implementation should have `opts.fs.mkdirSync(path, mode)` and
61`opts.fs.statSync(path)`.
62
63# usage
64
65This package also ships with a `mkdirp` command.
66
67```
68usage: mkdirp [DIR1,DIR2..] {OPTIONS}
69
70 Create each supplied directory including any necessary parent directories that
71 don't yet exist.
72
73 If the directory already exists, do nothing.
74
75OPTIONS are:
76
77 -m, --mode If a directory needs to be created, set the mode as an octal
78 permission string.
79
80```
81
82# install
83
84With [npm](http://npmjs.org) do:
85
86```
87npm install mkdirp
88```
89
90to get the library, or
91
92```
93npm install -g mkdirp
94```
95
96to get the command.
97
98# license
99
100MIT