deleteDir

Deletes a directory if it exists. Resolves the dirPath parameter if deletion succeeded or rejects a ENOENT or DeletingDirError.
Parameter ListReturnsRejection Errors
  • dirPath: string
  • tuple: Array (optional)
Promise<string || Array>
Related FunctionsFunction Signature
function deleteDir(dirPath[, tuple]): Promise<string || Array>
1 2 3 4 import {deleteDir} from 'puddy-m/lib/fileFunctions' deleteDir('path/to/existing/dir') .then(dirPath=>console.log(dirPath)) // prints 'path/to/existing/dir'
1 2 3 4 import {deleteDir} from 'puddy-m/lib/fileFunctions' deleteDir(true) .catch(e=>e) // rejects an instance of ENOENT or DeletingDirError.
1 2 3 4 5 6 // Using it with tuple parameter import {deleteDir} from 'puddy-m/lib/fileFunctions' deleteDir('path/to/existing/dir', []) .then(tuple=>validateString("World", tuple)) .then(([first, second])=> first + second) // 'path/to/existing/dirWorld'