From 6cf6b95e051d8ecde0424ff8bac022fee197c690 Mon Sep 17 00:00:00 2001 From: Dilum Aluthge Date: Sat, 29 May 2021 19:23:16 -0400 Subject: [PATCH] Refactor `write_manifest`, and add a method for `write_manifest` that prints the manifest to an IO (#2575) --- src/manifest.jl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/manifest.jl b/src/manifest.jl index 4951ede354..951ea9dca6 100644 --- a/src/manifest.jl +++ b/src/manifest.jl @@ -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