Add the package to the current env, not the global one

This commit is contained in:
Chris de Graaf 2018-11-09 16:44:58 -06:00
parent 250b97ad0a
commit 166cee2c34
3 changed files with 14 additions and 10 deletions

View File

@ -36,10 +36,10 @@ deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"
[[Mustache]]
deps = ["Pkg", "Tables", "Test"]
git-tree-sha1 = "1cee2f530502aa2357724e7b19af3239b2e7f6b7"
deps = ["Tables", "Test"]
git-tree-sha1 = "536782063c50421b05d1369bbd09fced13624361"
uuid = "ffc61752-8dc7-55ee-8c37-f3e9cdd09e70"
version = "0.5.5"
version = "0.5.7"
[[Pkg]]
deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
@ -73,10 +73,10 @@ uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[Tables]]
deps = ["Pkg", "Requires", "Test"]
git-tree-sha1 = "7b7e95a34c2c2504f1403aa9005399e239f461b9"
deps = ["Requires", "Test"]
git-tree-sha1 = "c7fb447deab835fa70ce6717e78c68b0f466a42c"
uuid = "bd369af6-aec1-5ad0-b16a-f7cc5008161c"
version = "0.1.9"
version = "0.1.11"
[[Test]]
deps = ["Distributed", "InteractiveUtils", "Logging", "Random"]

View File

@ -63,7 +63,7 @@ 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.
# Add the new package to the current environment.
Pkg.develop(PackageSpec(path=pkg_dir))
if length(collect(LibGit2.GitBranchIter(repo))) > 1
@ -113,6 +113,7 @@ 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")
@ -133,7 +134,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
Pkg.activate()
proj === nothing ? Pkg.activate() : Pkg.activate(proj)
end
pkg = basename(pkg_dir)

View File

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