| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3179,19 +3179,20 @@ Asynchronously creates a directory. | |||
| 3179 | 3179 | The callback is given a possible exception and, if `recursive` is `true`, the | |
| 3180 | 3180 | first directory path created, `(err[, path])`. | |
| 3181 | 3181 | `path` can still be `undefined` when `recursive` is `true`, if no directory was | |
| 3182 | - created. | ||
| 3182 | + created (for instance, if it was previously created). | ||
| 3183 | 3183 | ||
| 3184 | 3184 | The optional `options` argument can be an integer specifying `mode` (permission | |
| 3185 | 3185 | and sticky bits), or an object with a `mode` property and a `recursive` | |
| 3186 | 3186 | property indicating whether parent directories should be created. Calling | |
| 3187 | 3187 | `fs.mkdir()` when `path` is a directory that exists results in an error only | |
| 3188 | - when `recursive` is false. | ||
| 3188 | + when `recursive` is false. If `recursive` is false and the directory exists, | ||
| 3189 | + an `EEXIST` error occurs. | ||
| 3189 | 3190 | ||
| 3190 | 3191 | ```mjs | |
| 3191 | 3192 | import { mkdir } from 'node:fs'; | |
| 3192 | 3193 | ||
| 3193 | - // Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist. | ||
| 3194 | - mkdir('/tmp/a/apple', { recursive: true }, (err) => { | ||
| 3194 | + // Create ./tmp/a/apple, regardless of whether ./tmp and ./tmp/a exist. | ||
| 3195 | + mkdir('./tmp/a/apple', { recursive: true }, (err) => { | ||
| 3195 | 3196 | if (err) throw err; | |
| 3196 | 3197 | }); | |
| 3197 | 3198 | ``` | |
| Back | FazBrowse Home | New Git URL |
0 commit comments