Skip to content

Commit

Permalink
Add pkgdir (#674)
Browse files Browse the repository at this point in the history
  • Loading branch information
omus authored and martinholters committed Dec 25, 2019
1 parent 345c0fb commit 310219d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
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

0 comments on commit 310219d

Please sign in to comment.