The second one is very similar to how Pkg itself does it, so I would not say it’s hackish (unless you believe the approach of Pkg
itself to be hackish). If you want to match exactly how Pkg determines if a package is installed, use
isinstalled(pkg::AbstractString) =
pkg != "METADATA" && pkg != "REQUIRE" && pkg[1] != '.' && Pkg.cd(isdir, pkg)