root / HServer / 00.Server / 00.Program / node_modules / mkdirp / readme.markdown
이력 | 보기 | 이력해설 | 다운로드 (2.05 KB)
1 | 39 | HKM | # mkdirp |
---|---|---|---|
2 | |||
3 | Like `mkdir -p`, but in node.js! |
||
4 | |||
5 | [](http://travis-ci.org/substack/node-mkdirp) |
||
6 | |||
7 | # example |
||
8 | |||
9 | ## pow.js |
||
10 | |||
11 | ```js |
||
12 | var mkdirp = require('mkdirp'); |
||
13 | |||
14 | mkdirp('/tmp/foo/bar/baz', function (err) { |
||
15 | if (err) console.error(err) |
||
16 | else console.log('pow!') |
||
17 | }); |
||
18 | ``` |
||
19 | |||
20 | Output |
||
21 | |||
22 | ``` |
||
23 | pow! |
||
24 | ``` |
||
25 | |||
26 | And now /tmp/foo/bar/baz exists, huzzah! |
||
27 | |||
28 | # methods |
||
29 | |||
30 | ```js |
||
31 | var mkdirp = require('mkdirp'); |
||
32 | ``` |
||
33 | |||
34 | ## mkdirp(dir, opts, cb) |
||
35 | |||
36 | Create a new directory and any necessary subdirectories at `dir` with octal |
||
37 | permission string `opts.mode`. If `opts` is a non-object, it will be treated as |
||
38 | the `opts.mode`. |
||
39 | |||
40 | If `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` |
||
43 | that had to be created, if any. |
||
44 | |||
45 | You 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 | |||
51 | Synchronously create a new directory and any necessary subdirectories at `dir` |
||
52 | with octal permission string `opts.mode`. If `opts` is a non-object, it will be |
||
53 | treated as the `opts.mode`. |
||
54 | |||
55 | If `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`. |
||
56 | |||
57 | Returns the first directory that had to be created, if any. |
||
58 | |||
59 | You 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 | |||
65 | This package also ships with a `mkdirp` command. |
||
66 | |||
67 | ``` |
||
68 | usage: 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 | |||
75 | OPTIONS 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 | |||
84 | With [npm](http://npmjs.org) do: |
||
85 | |||
86 | ``` |
||
87 | npm install mkdirp |
||
88 | ``` |
||
89 | |||
90 | to get the library, or |
||
91 | |||
92 | ``` |
||
93 | npm install -g mkdirp |
||
94 | ``` |
||
95 | |||
96 | to get the command. |
||
97 | |||
98 | # license |
||
99 | |||
100 | MIT |