dirExists

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 ListReturnsRejection Errors
  • dirPath: string
  • tuple: Array (optional)
Promise<string || Array>
Related FunctionsFunction Signature
function dirExists(dirPath[, tuple]): Promise<string || Array>
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'