dirExists
Description
It resolves the dirPath if it points to an existing directory in the file system. If dirPath points to an non-existing directory, it will reject.
Parameter List | Returns | Rejection Errors |
---|---|---|
| Promise<string || Array> | |
Related Functions | Function Signature | |
function dirExists(dirPath[, tuple]): Promise<string || Array> |
Examples
1
2
3
4
import {dirExists} from 'puddy-m/lib/fileFunctions'
dirExists('path/to/supposed/dir')
.then(supposedDirPath=>console.log(supposedDirPath)) // prints 'path/to/supposed/dir'
1
2
3
4
import {dirExists} from 'puddy-m/lib/fileFunctions'
dirExists(true)
.catch(e=>e)
1
2
3
4
5
6
// Using it with tuple parameter
import {dirExists} from 'puddy-m/lib/fileFunctions'
dirExists('path/to/supposed/dir', [])
.then(tuple=>validateString("World", tuple))
.then(([first, second])=> first + second) // 'path/to/supposed/dirWorld'