diff --git a/inst/hooks/exported/lintr.R b/inst/hooks/exported/lintr.R index 21eb719a5..b8d25e652 100755 --- a/inst/hooks/exported/lintr.R +++ b/inst/hooks/exported/lintr.R @@ -3,14 +3,17 @@ "Run lintr on R files during a precommit. Usage: - lintr [--warn_only] ... + lintr [--warn_only] [--root=] ... Options: --warn_only Print lint warnings instead of blocking the commit. Should be used with `verbose: True` in `.pre-commit-config.yaml`. Otherwise, lints will never be shown to the user. + --root= Path relative to the git root that contains the R package root [default: .]. " -> doc arguments <- precommit::precommit_docopt(doc) +arguments$files <- normalizePath(arguments$files) # because working directory changes to root +setwd(normalizePath(arguments$root)) lintr_staged <- grepl( "modified:.*\\.lintr", system2("git", "status", stdout = TRUE)