Merge branch 'create-folder-if-not-exists'

This commit is contained in:
Angelos Chalaris
2019-01-09 19:44:14 +02:00
4 changed files with 470 additions and 76 deletions

View File

@ -0,0 +1,14 @@
### createDirIfNotExists
Creates a directory, if it does not exist.
Use `fs.existsSync()` to check if the directory exists, `fs.mkdirSync()` to create it.
```js
const fs = require('fs');
const createDirIfNotExists = dir => !fs.existsSync(dir) ? fs.mkdirSync(dir) : undefined;
```
```js
createDirIfNotExists('test'); // creates the directory 'test', if it doesn't exist
```