diff --git a/src/generate.jl b/src/generate.jl index 1508fe9..edaa3d5 100644 --- a/src/generate.jl +++ b/src/generate.jl @@ -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) diff --git a/test/tests.jl b/test/tests.jl index 58834d9..2ec7b70 100644 --- a/test/tests.jl +++ b/test/tests.jl @@ -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