Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor write_manifest, and add a method for write_manifest that prints the manifest to an IO #2575

Merged
merged 1 commit into from
May 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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