add ensureEmptyDir() and ensureEmptyDirSync()

This commit is contained in:
2017-01-01 02:45:53 +01:00
parent 395504127c
commit 3e1101c5e1
12 changed files with 146 additions and 84 deletions

View File

@ -89,6 +89,27 @@ export let ensureDirSync = (dirPathArg: string) => {
plugins.fsExtra.ensureDirSync(dirPathArg)
}
/**
* ensure an empty directory
* @executes ASYNC
*/
export let ensureEmptyDir = (dirPathArg: string) => {
let done = plugins.q.defer()
plugins.fsExtra.ensureDir(dirPathArg,() => {
plugins.fsExtra.emptyDir(dirPathArg, done.resolve)
})
return done.promise
}
/**
* ensure an empty directory
* @executes SYNC
*/
export let ensureEmptyDirSync = (dirPathArg: string) => {
plugins.fsExtra.ensureDirSync(dirPathArg)
plugins.fsExtra.emptyDirSync(dirPathArg)
}
/**
* ensures that a file is on disk
* @param filePath the filePath to ensureDir
@ -161,7 +182,6 @@ export let removeManySync = function(filePathArrayArg: string[]): void {
============================ Write/Read =========================
===============================================================*/
/**
*
* @param filePathArg