Skip to content

Commit

Permalink
strip .jl from package names
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Feb 20, 2017
1 parent 100bade commit f46e963
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
23 changes: 14 additions & 9 deletions src/PkgDev.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@ include("generate.jl")

const cd = Pkg.Dir.cd

# remove extension .jl
const PKGEXT = ".jl"
splitjl(pkg::AbstractString) = endswith(pkg, PKGEXT) ? pkg[1:end-length(PKGEXT)] : pkg

"""
dir(pkg, [paths...])
Return package `pkg` directory location through search. Additional `paths` are appended.
"""
function dir(pkg::AbstractString)
pkg = splitjl(pkg)
pkgsrc = Base.find_in_path(pkg, Pkg.dir())
pkgsrc === nothing && return ""
abspath(dirname(pkgsrc), "..") |> realpath
Expand All @@ -33,8 +38,8 @@ dir(pkg::AbstractString, args...) = normpath(dir(pkg),args...)
Register `pkg` at the git URL `url`, defaulting to the configured origin URL of the git
repo `Pkg.dir(pkg)`.
"""
register(pkg::AbstractString) = Entry.register(pkg)
register(pkg::AbstractString, url::AbstractString) = Entry.register(pkg,url)
register(pkg::AbstractString) = Entry.register(splitjl(pkg))
register(pkg::AbstractString, url::AbstractString) = Entry.register(splitjl(pkg),url)

"""
tag(pkg, [ver, [commit]])
Expand All @@ -44,15 +49,15 @@ not provided, `commit` defaults to the current commit of the `pkg` repo. If `ve
the symbols `:patch`, `:minor`, `:major` the next patch, minor or major version is used. If
`ver` is not provided, it defaults to `:patch`.
"""
tag(pkg::AbstractString, sym::Symbol=:patch) = cd(Entry.tag,pkg,sym)
tag(pkg::AbstractString, sym::Symbol, commit::AbstractString) = cd(Entry.tag,pkg,sym,false,commit)
tag(pkg::AbstractString, sym::Symbol=:patch) = cd(Entry.tag,splitjl(pkg),sym)
tag(pkg::AbstractString, sym::Symbol, commit::AbstractString) = cd(Entry.tag,splitjl(pkg),sym,false,commit)

tag(pkg::AbstractString, ver::VersionNumber; force::Bool=false) = cd(Entry.tag,pkg,ver,force)
tag(pkg::AbstractString, ver::VersionNumber; force::Bool=false) = cd(Entry.tag,splitjl(pkg),ver,force)
tag(pkg::AbstractString, ver::VersionNumber, commit::AbstractString; force::Bool=false) =
cd(Entry.tag,pkg,ver,force,commit)
cd(Entry.tag,splitjl(pkg),ver,force,commit)

submit(pkg::AbstractString) = cd(Entry.submit, pkg)
submit(pkg::AbstractString, commit::AbstractString) = cd(Entry.submit,pkg,commit)
submit(pkg::AbstractString) = cd(Entry.submit, splitjl(pkg))
submit(pkg::AbstractString, commit::AbstractString) = cd(Entry.submit,splitjl(pkg),commit)

"""
publish()
Expand Down Expand Up @@ -86,7 +91,7 @@ generate(pkg::AbstractString, license::AbstractString;
force::Bool=false, authors::Union{AbstractString,Array} = [],
config::Dict=Dict(), path::AbstractString = Pkg.Dir.path(),
travis::Bool = true, appveyor::Bool = true, coverage::Bool = true) =
Generate.package(pkg, license, force=force, authors=authors, config=config, path=path,
Generate.package(splitjl(pkg), license, force=force, authors=authors, config=config, path=path,
travis=travis, appveyor=appveyor, coverage=coverage)

"""
Expand Down
6 changes: 5 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ temp_pkg_dir() do pkgdir
end
end


@testset "generating a package with .jl extension" begin
PkgDev.generate("PackageWithExtension.jl", "MIT", config=Dict("user.name"=>"Julia Test", "user.email"=>"test@julialang.org"))
@show keys(Pkg.installed())
@test in("PackageWithExtension", [keys(Pkg.installed())...])
end

@testset "testing a package with no runtests.jl errors" begin
PkgDev.generate("PackageWithNoTests", "MIT", config=Dict("user.name"=>"Julia Test", "user.email"=>"test@julialang.org"))
Expand Down

0 comments on commit f46e963

Please sign in to comment.