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_project, and add a method for write_project that prints the project to an IO #2581

Merged
merged 1 commit into from
May 31, 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
14 changes: 8 additions & 6 deletions src/project.jl
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,14 @@ function write_project(env::EnvCache)
end
write_project(project::Project, project_file::AbstractString) =
write_project(destructure(project), project_file)
function write_project(project::Dict, project_file::AbstractString)
str = sprint() do io
TOML.print(io, project, sorted=true, by=key -> (project_key_order(key), key)) do x
(x isa UUID || x isa VersionNumber) && return string(x)
error("unhandled type `$(typeof(x))`")
end
function write_project(io::IO, project::Dict)
TOML.print(io, project, sorted=true, by=key -> (project_key_order(key), key)) do x
x isa UUID || x isa VersionNumber || pkgerror("unhandled type `$(typeof(x))`")
return string(x)
end
return nothing
end
function write_project(project::Dict, project_file::AbstractString)
str = sprint(write_project, project)
write(project_file, str)
end