async function deleteEmptyDirs(dir, startDir = dir) {
	const fileOrFolderList = readdirSync(dir);
	if (fileOrFolderList.length === 0) {
		await rmdir(dir);
		if (dir === startDir) {
			return;
		}
	}

	// if file is directory then recursively call deleteEmptyDirs
	for (const file of fileOrFolderList) {
		const filePath = join(dir, file);
		if (statSync(filePath).isDirectory()) {
			await deleteEmptyDirs(filePath, startDir);
		}
	}
}
Recursively deletes empty directories starting from the given directory
and moving upwards but stopping at the initial directory.
If the initial given directory is empty, it will be deleted.

@param {string} dir The directory to start deleting from
@param {string} startDir The initial directory to stop deleting at
@returns {Promise<void>} A promise that resolves when all empty directories have been deleted