node/deps/npm/node_modules/mkdirp/README.markdown

64 lines
1.1 KiB
Markdown
Raw Normal View History

2013-03-07 07:41:06 +08:00
# mkdirp
Like `mkdir -p`, but in node.js!
2012-06-05 08:32:46 +08:00
[![build status](https://secure.travis-ci.org/substack/node-mkdirp.png)](http://travis-ci.org/substack/node-mkdirp)
2013-03-07 07:41:06 +08:00
# example
2013-03-07 07:41:06 +08:00
## pow.js
```js
var mkdirp = require('mkdirp');
2013-03-07 07:41:06 +08:00
mkdirp('/tmp/foo/bar/baz', function (err) {
if (err) console.error(err)
else console.log('pow!')
});
```
Output
2013-03-07 07:41:06 +08:00
```
pow!
```
And now /tmp/foo/bar/baz exists, huzzah!
2013-03-07 07:41:06 +08:00
# methods
2013-03-07 07:41:06 +08:00
```js
var mkdirp = require('mkdirp');
2013-03-07 07:41:06 +08:00
```
2013-03-07 07:41:06 +08:00
## mkdirp(dir, mode, cb)
Create a new directory and any necessary subdirectories at `dir` with octal
permission string `mode`.
If `mode` isn't specified, it defaults to `0777 & (~process.umask())`.
2012-06-05 08:32:46 +08:00
`cb(err, made)` fires with the error or the first directory `made`
that had to be created, if any.
2013-03-07 07:41:06 +08:00
## mkdirp.sync(dir, mode)
Synchronously create a new directory and any necessary subdirectories at `dir`
with octal permission string `mode`.
If `mode` isn't specified, it defaults to `0777 & (~process.umask())`.
2012-06-05 08:32:46 +08:00
Returns the first directory that had to be created, if any.
2013-03-07 07:41:06 +08:00
# install
With [npm](http://npmjs.org) do:
2013-03-07 07:41:06 +08:00
```
npm install mkdirp
```
2013-03-07 07:41:06 +08:00
# license
2013-03-07 07:41:06 +08:00
MIT