def get_bun_version(bun_path: Path | None = None) -> version.Version | None:
    """Get the version of bun.

    Args:
        bun_path: The path to the bun executable.

    Returns:
        The version of bun.
    """
    bun_path = bun_path or path_ops.get_bun_path()
    if bun_path is None:
        return None
    try:
        # Run the bun -v command and capture the output
        result = processes.new_process([str(bun_path), "-v"], run=True)
        return version.parse(str(result.stdout))
    except FileNotFoundError:
        return None
    except version.InvalidVersion as e:
        console.warn(
            f"The detected bun version ({e.args[0]}) is not valid. Defaulting to None."
        )
        return None
Get the version of bun.

    Args:
        bun_path: The path to the bun executable.

    Returns:
        The version of bun.
    
reflex/utils/prerequisites.py