Add new packages to the global environment

This commit is contained in:
Chris de Graaf 2018-11-09 15:55:12 -06:00
parent 2822ae4619
commit 250b97ad0a
2 changed files with 11 additions and 2 deletions

View File

@ -63,6 +63,9 @@ function generate(
LibGit2.commit(repo, "Files generated by PkgTemplates")
@info "Committed $(length(files)) files/directories: $(join(files, ", "))"
# Add the new package to the global environment.
Pkg.develop(PackageSpec(path=pkg_dir))
if length(collect(LibGit2.GitBranchIter(repo))) > 1
@info "Remember to push all created branches to your remote: git push --all"
end
@ -110,7 +113,6 @@ Returns an array of generated file/directory names.
"""
function gen_tests(pkg_dir::AbstractString, t::Template)
# TODO: Silence Pkg for this section? Adding and removing Test creates a lot of noise.
proj = Base.current_project()
try
Pkg.activate(pkg_dir)
Pkg.add("Test")
@ -131,7 +133,7 @@ function gen_tests(pkg_dir::AbstractString, t::Template)
gen_file(joinpath(pkg_dir, "Project.toml"), toml)
Pkg.update() # Regenerate Manifest.toml (this cleans up Project.toml too).
finally
proj !== nothing && Pkg.activate(dirname(proj))
Pkg.activate()
end
pkg = basename(pkg_dir)

View File

@ -319,6 +319,13 @@ end
idx = LibGit2.GitIndex(repo)
@test findall("Manifest.toml", idx) !== nothing
rm(pkg_dir; recursive=true)
# Check that the created package ends up developed in the global environment.
t = Template(; user=me)
generate(test_pkg, t; gitconfig=gitconfig)
Pkg.activate()
@test haskey(Pkg.installed(), test_pkg)
rm(pkg_dir; recursive=true)
end
@testset "Version floor" begin