Skip to contents

The 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.

Usage

manifest_merge(path, patch)

Arguments

path

the manifest file path (*.manifest.json)

patch

a named list of top-level keys to set

Value

(invisibly) the manifest path

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.

Author

Daniel Lakens and Levi Baruch

Examples

path <- tempfile(fileext = ".manifest.json")
writeLines("{}", path)
manifest_merge(path, list(paper_id = "stroop_effect"))
readLines(path)
#> [1] "{"                                 "  \"paper_id\": \"stroop_effect\""
#> [3] "}"