Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pkgdir #674

Merged
merged 6 commits into from
Dec 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Please check the list below for the specific syntax you need.

## Supported features

* `pkgdir(m)` returns the root directory of the package that imported module `m` ([#33128]). (since Compat 3.2.0)

* `filter` can now act on a `Tuple` [#32968]. (since Compat 3.1.0)

* `Base.Order.ReverseOrdering` has a zero arg constructor [#33736]. (since Compat 3.0.0)
Expand Down Expand Up @@ -104,5 +106,6 @@ Note that you should specify the correct minimum version for `Compat` in the
[#32628]: https://github.com/JuliaLang/julia/issues/32628
[#33129]: https://github.com/JuliaLang/julia/issues/33129
[#33568]: https://github.com/JuliaLang/julia/pull/33568
[#33128]: https://github.com/JuliaLang/julia/pull/33128
[#33736]: http://github.com/JuliaLang/julia/pull/33736
[#32968]: https://github.com/JuliaLang/julia/pull/32968
11 changes: 11 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ if VERSION < v"1.4.0-DEV.329"
Base.:∘(f, g, h...) = ∘(f ∘ g, h...)
end

# https://github.com/JuliaLang/julia/pull/33128
if VERSION < v"1.4.0-DEV.397"
export pkgdir
function pkgdir(m::Module)
rootmodule = Base.moduleroot(m)
path = pathof(rootmodule)
path === nothing && return nothing
return dirname(dirname(path))
end
end

# https://github.com/JuliaLang/julia/pull/33736/
if VERSION < v"1.4.0-DEV.493"
Base.Order.ReverseOrdering() = Base.Order.ReverseOrdering(Base.Order.Forward)
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ end
@test ∘(fs...)("ABC") == "AB"
end

# https://github.com/JuliaLang/julia/pull/33128
@testset "pkgdir" begin
@test pkgdir(Main) === nothing
@test joinpath(pkgdir(Compat), "") == abspath(joinpath(@__DIR__, ".."))
end

# https://github.com/JuliaLang/julia/pull/33736/
@testset "ReverseOrdering constructor" begin
@test Base.Order.ReverseOrdering() == Base.Order.Reverse
Expand Down