Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
bin/ | 12-May-2024 | - | 47 | 34 | ||
node_modules/minimist/ | 12-May-2024 | - | 1,307 | 1,118 | ||
LICENSE | D | 12-May-2024 | 1.1 KiB | 22 | 17 | |
README.markdown | D | 12-May-2024 | 2 KiB | 101 | 63 | |
index.js | D | 12-May-2024 | 2.6 KiB | 100 | 77 | |
package.json | D | 12-May-2024 | 1.8 KiB | 84 | 83 |
README.markdown
1# mkdirp 2 3Like `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 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`. 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`. 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 101