|
| 1 | +#!/usr/bin/env Rscript |
| 2 | + |
| 3 | +"Validate renv lockfiles |
| 4 | +See `?renv::lockfile_validate()`. |
| 5 | +Usage: |
| 6 | + lockfile_validate [--schema=<schema>] [--greedy --error --verbose --strict] <files>... |
| 7 | +Options: |
| 8 | + --schema Path. Path to a custom schema. |
| 9 | + --greedy Continue after first error? |
| 10 | + --error Throw an error on parse failure? |
| 11 | + --verbose If `TRUE`, then an attribute `errors` will list validation failures as a `data.frame`. |
| 12 | + --strict Set whether the schema should be parsed strictly or not. |
| 13 | +" -> doc |
| 14 | + |
| 15 | +if (!require(renv, quietly = TRUE)) { |
| 16 | + stop("{renv} could not be loaded, please install it.") |
| 17 | +} |
| 18 | +if (packageVersion("renv") < package_version("1.0.8")) { |
| 19 | + rlang::abort("You need at least version 1.0.8 of {renv} to run this hook.") |
| 20 | +} |
| 21 | +if (!require(jsonvalidate, quietly = TRUE)) { |
| 22 | + stop("{jsonvalidate} could not be loaded, please install it.") |
| 23 | +} |
| 24 | + |
| 25 | +arguments <- precommit::precommit_docopt(doc) |
| 26 | +arguments$files <- normalizePath(arguments$files) |
| 27 | +if (!is.null(arguments$schema)) { |
| 28 | + arguments$schema <- normalizePath(arguments$schema) |
| 29 | +} |
| 30 | + |
| 31 | +renv::lockfile_validate( |
| 32 | + lockfile = arguments$files, |
| 33 | + schema = arguments$schema, |
| 34 | + greedy = arguments$greedy, |
| 35 | + error = arguments$error, |
| 36 | + verbose = arguments$verbose, |
| 37 | + strict = arguments$strict |
| 38 | +) |
0 commit comments