diff --git a/src/generate.jl b/src/generate.jl index 6faec5b..cd846fa 100644 --- a/src/generate.jl +++ b/src/generate.jl @@ -217,7 +217,7 @@ end """ gen_file(file_path::AbstractString, text::AbstractString) -> Void -Create a new file containing some given text. +Create a new file containing some given text. Always ends the file with a newline. # Arguments * `file::AbstractString`: Path to the file to be created. diff --git a/src/license.jl b/src/license.jl index 1b3a2ab..bb7ceb3 100644 --- a/src/license.jl +++ b/src/license.jl @@ -4,8 +4,8 @@ Show all available license names. """ function show_license() - for k in sort!(collect(keys(LICENSES))) - println("$k: $(LICENSES[k])") + for (k, v) in LICENSES + println("$k: $v") end end @@ -19,7 +19,7 @@ Shows the text of a given `license`. The list of available licenses can be shown with `show_license()`. """ function show_license(license::AbstractString) - print(read_license(license)) + println(read_license(license)) end """ @@ -34,9 +34,9 @@ Returns the license text. """ function read_license(license::AbstractString) path = joinpath(LICENSE_DIR, license) - if !isfile(path) - throw(ArgumentError("License '$license' is not available")) + if isfile(path) + return string(readchomp(path)) else - return readstring(path) + throw(ArgumentError("License '$license' is not available")) end end diff --git a/src/template.jl b/src/template.jl index dea1aba..86f65b2 100644 --- a/src/template.jl +++ b/src/template.jl @@ -45,7 +45,12 @@ Records common information used to generate a package. throw(ArgumentError("Must specify remote_prefix::AbstractString")) end years = string(years) - if isa(authors, Array) + + # If an explicitly supplied git config contains a name and the author name was not + # explicitly supplied, then take the git config's name as the author name. + if haskey(git_config, "user.name") && authors == LibGit2.getconfig("user.name", "") + authors = get(git_config, "user.name", LibGit2.getconfig("user.name", "")) + elseif isa(authors, Array) authors = join(authors, ", ") end if !endswith(remote_prefix, "/")