createDir
Description
Creates a directory based on the dirPath parameter. It resolves dirPath if successful, but rejects a CreatingDirError instance if it fails.
Parameter List | Returns | Rejection Errors |
---|---|---|
| Promise<string || Array> | |
Related Functions | Function Signature | |
function createDir(dirPath[, tuple]): Promise<string || Array> |
Examples
1
2
3
4
import {createDir} from 'puddy-m/lib/fileFunctions'
createDir('path/to/dir')
.then(dirPath=>console.log(dirPath)) // prints 'path/to/dir'
1
2
3
4
import {createDir} from 'puddy-m/lib/fileFunctions'
createDir(true)
.catch(e=>e) // rejects an ENOENT or CreatingDirError.
1
2
3
4
5
6
// Using it with tuple parameter
import {createDir} from 'puddy-m/lib/fileFunctions'
createDir('path/to/dir1', [])
.then(tuple=>validateString('World', tuple))
.then(([dir1, str])=> first + ' - ' + str) // "path/to/dir1 - World"