fix deleteEmptyFolder api issues

This commit is contained in:
Abhinav 2023-04-25 18:23:03 +05:30
parent fff374d7fb
commit b86620f051

View file

@ -262,11 +262,8 @@ export async function moveFile(
export async function deleteEmptyFolder(folderPath: string) {
if (!existsSync(folderPath)) {
throw new Error('Folder does not exist');
}
const files = await fs.readdir(folderPath);
if (files.length > 0) {
throw new Error('Folder is not empty');
return;
}
// TODO: handle error and throw custom error
await fs.rmdir(folderPath);
}