from pathlib import Path
from typing import Optional


def get_current_version(datadir: Path) -> Optional[str]:
    """Retrieves current version from the app data directory, if it exists

    Args:
        datadir (Path): Path of the data directory

    Returns:
        Optional[str]: The current version, otherwise None
    """
    if datadir.joinpath("VERSION").exists():
        return datadir.joinpath("VERSION").read_text().strip()
    return None