Skip to content

Commit 1238bad

Browse files
Merge pull request #25280 from lakshayg/fix/Pkg_status
update Pkg.status to throw if pkg does not exist
2 parents c44883e + a93b8b2 commit 1238bad

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

base/pkg/entry.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ function installed(pkg::AbstractString)
127127
end
128128

129129
function status(io::IO; pkgname::AbstractString = "")
130+
if !isempty(pkgname) && !ispath(pkgname)
131+
throw(PkgError("Package $pkgname does not exist"))
132+
end
130133
showpkg(pkg) = isempty(pkgname) ? true : (pkg == pkgname)
131134
reqs = Reqs.parse("REQUIRE")
132135
instd = Read.installed()
@@ -158,6 +161,9 @@ end
158161
status(io::IO, pkg::AbstractString) = status(io, pkgname = pkg)
159162

160163
function status(io::IO, pkg::AbstractString, ver::VersionNumber, fix::Bool)
164+
if !isempty(pkg) && !ispath(pkg)
165+
throw(PkgError("Package $pkg does not exist"))
166+
end
161167
@printf io " - %-29s " pkg
162168
fix || return println(io,ver)
163169
@printf io "%-19s" ver

test/pkg.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ temp_pkg_dir() do
6363
end
6464

6565
@test_throws PkgError Pkg.installed("MyFakePackage")
66+
@test_throws PkgError Pkg.status("MyFakePackage")
6667
@test Pkg.installed("Example") === nothing
6768

6869
# Check that setprotocol! works.

0 commit comments

Comments
 (0)