From 5c554026de88c313d1f44c515ee519e34734430e Mon Sep 17 00:00:00 2001 From: Jack Dunn Date: Tue, 26 Feb 2019 11:45:15 -0500 Subject: [PATCH] Create dir in `withfile` if needed --- src/Documenter.jl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Documenter.jl b/src/Documenter.jl index d9cd2b3aeb0..b7143854963 100644 --- a/src/Documenter.jl +++ b/src/Documenter.jl @@ -747,6 +747,10 @@ function gitrm_copy(src, dst) end function withfile(func, file::AbstractString, contents::AbstractString) + dir = dirname(file) + hasdir = isdir(dir) + hasdir || mkpath(dir) + hasfile = isfile(file) original = hasfile ? read(file, String) : "" open(file, "w") do stream @@ -763,6 +767,11 @@ function withfile(func, file::AbstractString, contents::AbstractString) else rm(file) end + + if !hasdir + # dir should be empty now as the only file inside was deleted + rm(dir, recursive=true) + end end end