write out a codemeta.json file for a given package. This function is basically a wrapper around create_codemeta() to both create the codemeta object and write it out to a JSON-LD-formatted file in one command. It can also be used simply to write out to JSON-LD any existing object created with create_codemeta().

write_codemeta(pkg = ".", path = "codemeta.json", root = ".",
  id = NULL, use_filesize = FALSE,
  force_update = getOption("codemeta_force_update", TRUE),
  use_git_hook = FALSE, verbose = TRUE, ...)



package path to package root, or package name, or description file (character), or a codemeta object (list)


file name of the output, leave at default "codemeta.json"


if pkg is a codemeta object, optionally give the path to package root. Default guess is current dir.


identifier for the package, e.g. a DOI (or other resolvable URL)


whether to try to estimating and adding a filesize by using base::files.ize(). Files in .Rbuildignore are ignored.


Update guessed fields even if they are defined in an existing codemeta.json file


Whether to create a pre-commit hook requiring codemeta.json to be updated when DESCRIPTION is changed. Default is FALSE to avoid an unwanted alteration of the user's git environment.


Whether to print messages indicating opinions e.g. when DESCRIPTION has no URL. See give_opinions.


additional arguments to write_json


writes out the codemeta.json file


If pkg is a codemeta object, the function will attempt to update any fields it can guess (i.e. from the DESCRIPTION file), overwriting any existing data in that block. In this case, the package root directory should be the current working directory.

When creating and writing a codemeta.json for the first time, the function adds "codemeta.json" to .Rbuildignore and, if the project uses git, adds a pre-commit hook ensuring that if DESCRIPTION changes, the codemeta.json will be updated as well unless the DESCRIPTION change is committed with 'git commit --no-verify'.


write_codemeta("codemetar", path = "example_codemetar_codemeta.json")
#> Error: File `/home/travis/build/ropensci/codemetar/inst/DESCRIPTION' does not exist