From 63e1b73c418380468e37446b9f1b9e7ea65d121d Mon Sep 17 00:00:00 2001 From: Stefan Karpinski Date: Tue, 20 Aug 2013 14:37:54 -0400 Subject: [PATCH] Pkg.scaffold(dir=): allow scaffolding with any name elsewhere. This allows creation of new package scaffolding using the same code that won't have any interaction with the existing registered or installed packages as requested by @johnmyleswhite. --- base/pkg/scaffold.jl | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/base/pkg/scaffold.jl b/base/pkg/scaffold.jl index d65485814cc18..7159b7a50a5a0 100644 --- a/base/pkg/scaffold.jl +++ b/base/pkg/scaffold.jl @@ -4,21 +4,26 @@ using Base.Git, ..Dir, ..Read function scaffold( pkg::String; - license = nothing, + dir::String = "", + license::String = "", years::Union(Int,String) = readchomp(`date +%Y`), authors::String = Git.readchomp(`config --global --get user.name`), ) - license === nothing && error(""" - No license chosen -- you must choose a license, e.g.: + isempty(license) && error(""" + No license chosen -- you must choose a license, e.g.: - julia> Pkg.scaffold("$pkg", license="MIT") - """) + julia> Pkg.scaffold("$pkg", license="MIT") + """) haskey(LICENSES,license) || error("$license is not a known license choice.") - avail = Dir.cd(Read.available) - haskey(avail,pkg) && - error("$pkg is already a registered package name.") - d = Dir.path(pkg) + d = if isempty(dir) + avail = Dir.cd(Read.available) + haskey(avail,pkg) && + error("$pkg is already a registered package name.") + Dir.path(pkg) + else + joinpath(dir,pkg) + end ispath(d) && error("$d exists, refusing to overwrite.") mkpath(d)