Skip to content

Commit

Permalink
fix: Fixed deleting unversioned folders with nested files #554 (#555)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanpas authored and JohnstonCode committed Apr 24, 2019
1 parent 622e6b8 commit 6cf322c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ export function isReadOnly(operation: Operation): boolean {
* @see https://stackoverflow.com/a/42505874/3027390
*/
export async function deleteDirectory(dirPath: string): Promise<void> {
if (await exists(dirPath) && (await lstat(dirPath)).isDirectory()) {
(await readdir(dirPath)).forEach(async (entry: string) => {
if ((await exists(dirPath)) && (await lstat(dirPath)).isDirectory()) {
await Promise.all((await readdir(dirPath)).map(async (entry: string) => {
const entryPath = path.join(dirPath, entry);
if ((await lstat(entryPath)).isDirectory()) {
deleteDirectory(entryPath);
await deleteDirectory(entryPath);
} else {
await unlink(entryPath);
}
});
}));
await rmdir(dirPath);
}
}
Expand Down

0 comments on commit 6cf322c

Please sign in to comment.