Skip to content

Commit

Permalink
Refactor write_manifest, and add a method for write_manifest that…
Browse files Browse the repository at this point in the history
… prints the manifest to an IO
  • Loading branch information
DilumAluthge committed May 28, 2021
1 parent 9f67253 commit 5d8e0c6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/manifest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -236,13 +236,15 @@ function write_manifest(env::EnvCache)
end
write_manifest(manifest::Manifest, manifest_file::AbstractString) =
write_manifest(destructure(manifest), manifest_file)
function write_manifest(manifest::Dict, manifest_file::AbstractString)
str = sprint() do io
print(io, "# This file is machine-generated - editing it directly is not advised\n\n")
TOML.print(io, manifest, sorted=true) do x
(x isa UUID || x isa SHA1 || x isa VersionNumber) && return string(x)
error("unhandled type `$(typeof(x))`")
end
function write_manifest(io::IO, manifest::Dict)
print(io, "# This file is machine-generated - editing it directly is not advised\n\n")
TOML.print(io, manifest, sorted=true) do x
x isa UUID || x isa SHA1 || x isa VersionNumber || pkgerror("unhandled type `$(typeof(x))`")
return string(x)
end
return nothing
end
function write_manifest(manifest::Dict, manifest_file::AbstractString)
str = sprint(write_manifest, manifest)
write(manifest_file, str)
end

0 comments on commit 5d8e0c6

Please sign in to comment.