Skip to content

Commit 6cf322c

Browse files
YanpasJohnstonCode
authored andcommitted
fix: Fixed deleting unversioned folders with nested files #554 (#555)
1 parent 622e6b8 commit 6cf322c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/util.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,15 @@ export function isReadOnly(operation: Operation): boolean {
170170
* @see https://stackoverflow.com/a/42505874/3027390
171171
*/
172172
export async function deleteDirectory(dirPath: string): Promise<void> {
173-
if (await exists(dirPath) && (await lstat(dirPath)).isDirectory()) {
174-
(await readdir(dirPath)).forEach(async (entry: string) => {
173+
if ((await exists(dirPath)) && (await lstat(dirPath)).isDirectory()) {
174+
await Promise.all((await readdir(dirPath)).map(async (entry: string) => {
175175
const entryPath = path.join(dirPath, entry);
176176
if ((await lstat(entryPath)).isDirectory()) {
177-
deleteDirectory(entryPath);
177+
await deleteDirectory(entryPath);
178178
} else {
179179
await unlink(entryPath);
180180
}
181-
});
181+
}));
182182
await rmdir(dirPath);
183183
}
184184
}

0 commit comments

Comments
 (0)