Skip to content

Commit

Permalink
Change devdir kwarg to shared in REPL mode, add the kwarg to the API (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre authored and KristofferC committed Aug 4, 2018
1 parent f4d0411 commit 94eec9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 4 additions & 5 deletions stdlib/Pkg/src/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ add_or_develop(pkg::Union{String, PackageSpec}; kwargs...) = add_or_develop([pkg
add_or_develop(pkgs::Vector{String}; kwargs...) = add_or_develop([check_package_name(pkg) for pkg in pkgs]; kwargs...)
add_or_develop(pkgs::Vector{PackageSpec}; kwargs...) = add_or_develop(Context(), pkgs; kwargs...)

function add_or_develop(ctx::Context, pkgs::Vector{PackageSpec}; mode::Symbol, devdir::Bool=false, kwargs...)
function add_or_develop(ctx::Context, pkgs::Vector{PackageSpec}; mode::Symbol, shared::Bool=true, kwargs...)
Context!(ctx; kwargs...)

devdir = devdir ? joinpath(dirname(ctx.env.project_file), "dev") : nothing

# All developed packages should go through handle_repos_develop so just give them an empty repo
for pkg in pkgs
mode == :develop && pkg.repo == nothing && (pkg.repo = Types.GitRepo())
Expand All @@ -45,7 +43,8 @@ function add_or_develop(ctx::Context, pkgs::Vector{PackageSpec}; mode::Symbol, d

ctx.preview && preview_info()
if mode == :develop
new_git = handle_repos_develop!(ctx, pkgs, something(devdir, Pkg.devdir()))
devdir = shared ? Pkg.devdir() : joinpath(dirname(ctx.env.project_file), "dev")
new_git = handle_repos_develop!(ctx, pkgs, devdir)
else
new_git = handle_repos_add!(ctx, pkgs; upgrade_or_add=true)
end
Expand All @@ -63,7 +62,7 @@ function add_or_develop(ctx::Context, pkgs::Vector{PackageSpec}; mode::Symbol, d
end

add(args...; kwargs...) = add_or_develop(args...; mode = :add, kwargs...)
develop(args...; kwargs...) = add_or_develop(args...; mode = :develop, kwargs...)
develop(args...; shared=true, kwargs...) = add_or_develop(args...; mode = :develop, shared = shared, kwargs...)

rm(pkg::Union{String, PackageSpec}; kwargs...) = rm([pkg]; kwargs...)
rm(pkgs::Vector{String}; kwargs...) = rm([PackageSpec(pkg) for pkg in pkgs]; kwargs...)
Expand Down
4 changes: 2 additions & 2 deletions stdlib/Pkg/src/REPLMode.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1037,8 +1037,8 @@ pkg> add Example=7876af07-990d-54b4-ab0e-23690620f79a
do_develop!,
(ARG_ALL, []),
[
("local", OPT_SWITCH, :devdir => true),
("shared", OPT_SWITCH, :devdir => false),
("local", OPT_SWITCH, :shared => false),
("shared", OPT_SWITCH, :shared => true),
],
md"""
develop [--shared|--local] pkg[=uuid] [#rev] ...
Expand Down

0 comments on commit 94eec9b

Please sign in to comment.