fix deleteEmptyFolder api issues
This commit is contained in:
parent
fff374d7fb
commit
b86620f051
|
@ -262,11 +262,8 @@ export async function moveFile(
|
||||||
|
|
||||||
export async function deleteEmptyFolder(folderPath: string) {
|
export async function deleteEmptyFolder(folderPath: string) {
|
||||||
if (!existsSync(folderPath)) {
|
if (!existsSync(folderPath)) {
|
||||||
throw new Error('Folder does not exist');
|
return;
|
||||||
}
|
|
||||||
const files = await fs.readdir(folderPath);
|
|
||||||
if (files.length > 0) {
|
|
||||||
throw new Error('Folder is not empty');
|
|
||||||
}
|
}
|
||||||
|
// TODO: handle error and throw custom error
|
||||||
await fs.rmdir(folderPath);
|
await fs.rmdir(folderPath);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue