deleteDir
Description
Deletes a directory if it exists. Resolves the dirPath parameter if deletion succeeded or rejects a ENOENT or DeletingDirError.
Parameter List | Returns | Rejection Errors |
---|---|---|
| Promise<string || Array> | |
Related Functions | Function Signature | |
function deleteDir(dirPath[, tuple]): Promise<string || Array> |
Examples
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'