選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

1234567891011121314151617181920212223242526272829
  1. # ensureDir(dir, [callback])
  2. Ensures that the directory exists. If the directory structure does not exist, it is created. Like `mkdir -p`.
  3. **Aliases:** `mkdirs()`, `mkdirp()`
  4. - `dir` `<String>`
  5. - `callback` `<Function>`
  6. ## Example:
  7. ```js
  8. const fs = require('fs-extra')
  9. const dir = '/tmp/this/path/does/not/exist'
  10. fs.ensureDir(dir, err => {
  11. console.log(err) // => null
  12. // dir has now been created, including the directory it is to be placed in
  13. })
  14. // With Promises:
  15. fs.ensureDir(dir)
  16. .then(() => {
  17. console.log('success!')
  18. })
  19. .catch(err => {
  20. console.error(err)
  21. })
  22. ```