
Merge fields into a metacheck manifest, preserving other sections
Source:R/data_check_helpers.R
manifest_merge.RdThe per-paper *.manifest.json is written by more than one module:
data_check records the files/provenance, and code_check records the
packages the code loads (a code section). Because each module rebuilds only
its own part of the document, a plain overwrite would let whichever module ran
last erase the other's section. This helper reads any existing manifest,
overlays patch at the top level (each key in patch replaces that key
wholesale; keys not in patch are kept untouched), and writes it back.
Details
The rule that makes this safe against run order: each writer's patch must
contain only the keys it owns. data_check patches everything except code;
code_check patches only code. Overlapping keys would still clobber.
Examples
path <- tempfile(fileext = ".manifest.json")
writeLines("{}", path)
manifest_merge(path, list(paper_id = "stroop_effect"))
readLines(path)
#> [1] "{" " \"paper_id\": \"stroop_effect\""
#> [3] "}"