3 Like `mkdir -p`, but in node.js!
5 [![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp)
12 var mkdirp = require('mkdirp');
14 mkdirp('/tmp/foo/bar/baz', function (err) {
15 if (err) console.error(err)
16 else console.log('pow!')
26 And now /tmp/foo/bar/baz exists, huzzah!
31 var mkdirp = require('mkdirp');
34 ## mkdirp(dir, opts, cb)
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
40 If `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`.
42 `cb(err, made)` fires with the error or the first directory `made`
43 that had to be created, if any.
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)`.
49 ## mkdirp.sync(dir, opts)
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`.
55 If `opts.mode` isn't specified, it defaults to `0777 & (~process.umask())`.
57 Returns the first directory that had to be created, if any.
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)`.
65 This package also ships with a `mkdirp` command.
68 usage: mkdirp [DIR1,DIR2..] {OPTIONS}
70 Create each supplied directory including any necessary parent directories that
73 If the directory already exists, do nothing.
77 -m, --mode If a directory needs to be created, set the mode as an octal
84 With [npm](http://npmjs.org) do:
90 to get the library, or