-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move direct wrapper functions to internal module Copier
- Loading branch information
1 parent
127d058
commit f7afcf3
Showing
5 changed files
with
68 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
Wrapper around [copier](https://copier.readthedocs.io/). | ||
There are three functions in this module: | ||
- [`copy`](@ref) | ||
- [`recopy`](@ref) | ||
- [`update`](@ref) | ||
""" | ||
module Copier | ||
|
||
using CondaPkg: CondaPkg | ||
using PythonCall: PythonCall | ||
|
||
function __init__() | ||
CondaPkg.add("copier") | ||
end | ||
|
||
""" | ||
copy(dst_path[, data]; kwargs...) | ||
copy(src_path, dst_path[, data]; kwargs...) | ||
Wrapper around [copier.run_copy](https://copier.readthedocs.io/en/stable/reference/main/#copier.main.run_copy). | ||
This is an internal function, if COPIERTemplate's main API is not sufficient, open an issue. | ||
""" | ||
function Base.copy(src_path, dst_path, data::Dict = Dict(); kwargs...) | ||
copier = PythonCall.pyimport("copier") | ||
copier.run_copy(src_path, dst_path, data; kwargs...) | ||
end | ||
|
||
function Base.copy(dst_path, data::Dict = Dict(); kwargs...) | ||
copy(joinpath(@__DIR__, ".."), dst_path, data; kwargs...) | ||
end | ||
|
||
""" | ||
recopy(dst_path[, data]; kwargs...) | ||
Wrapper around [copier.run_recopy](https://copier.readthedocs.io/en/stable/reference/main/#copier.main.run_recopy). | ||
This is an internal function, if COPIERTemplate's main API is not sufficient, open an issue. | ||
""" | ||
function recopy(dst_path, data::Dict = Dict(); kwargs...) | ||
copier = PythonCall.pyimport("copier") | ||
copier.run_recopy(dst_path, data; kwargs...) | ||
end | ||
|
||
""" | ||
update(dst_path[, data]; kwargs...) | ||
Wrapper around [copier.run_update](https://copier.readthedocs.io/en/stable/reference/main/#copier.main.run_update). | ||
This is an internal function, if COPIERTemplate's main API is not sufficient, open an issue. | ||
""" | ||
function update(dst_path, data::Dict = Dict(); kwargs...) | ||
copier = PythonCall.pyimport("copier") | ||
copier.run_update(dst_path, data; kwargs...) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,15 +111,15 @@ end | |
|
||
@testset "Compare copied project vs copier CLI baseline" begin | ||
mktempdir(TMPDIR; prefix = "copy_") do tmpdir | ||
COPIERTemplate.copy(tmpdir, template_options; quiet = true) | ||
COPIERTemplate.Copier.copy(tmpdir, template_options; quiet = true) | ||
test_diff_dir(tmpdir, dir_copier_cli) | ||
end | ||
end | ||
|
||
@testset "Compare recopied project vs copier CLI baseline" begin | ||
mktempdir(TMPDIR; prefix = "recopy_") do tmpdir | ||
run(`copier copy --defaults --quiet $min_bash_args $template_path $tmpdir`) | ||
COPIERTemplate.recopy(tmpdir, template_options; quiet = true, overwrite = true) | ||
COPIERTemplate.Copier.recopy(tmpdir, template_options; quiet = true, overwrite = true) | ||
test_diff_dir(tmpdir, dir_copier_cli) | ||
end | ||
end | ||
|
@@ -134,7 +134,7 @@ end | |
run(`git config user.email "[email protected]"`) | ||
run(`git commit -q -m "First commit"`) | ||
end | ||
COPIERTemplate.update(tmpdir, template_options; overwrite = true, quiet = true) | ||
COPIERTemplate.Copier.update(tmpdir, template_options; overwrite = true, quiet = true) | ||
test_diff_dir(tmpdir, dir_copier_cli) | ||
end | ||
end | ||
|