Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
# ensureDirSync(dir) | ||
# ensureDirSync(dir[,options]) | ||
|
||
Ensures that the directory exists. If the directory structure does not exist, it is created. Like `mkdir -p`. | ||
Ensures that the directory exists. If the directory structure does not exist, it is created. Like `mkdir -p`. If provided, options may specify the desired mode for the directory. | ||
|
||
**Aliases:** `mkdirsSync()`, `mkdirpSync()` | ||
|
||
- `dir` `<String>` | ||
|
||
- `options` `<Integer>|<Object>` | ||
## Example: | ||
|
||
```js | ||
const fs = require('fs-extra') | ||
|
||
const dir = '/tmp/this/path/does/not/exist' | ||
|
||
const desiredMode = 0o2775 | ||
const options = { | ||
mode: 0o2775 | ||
} | ||
|
||
fs.ensureDirSync(dir) | ||
// dir has now been created, including the directory it is to be placed in | ||
|
||
fs.ensureDirSync(dir, desiredMod) | ||
// dir has now been created, including the directory it is to be placed in with permission 0o2775 | ||
|
||
fs.ensureDirSync(dir, options) | ||
// dir has now been created, including the directory it is to be placed in with permission 0o2775 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters