Skip to content

Commit

Permalink
feat: add --root argument to lintr hook
Browse files Browse the repository at this point in the history
  • Loading branch information
TymekDev committed Oct 18, 2024
1 parent 9525a2e commit 10bd189
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion inst/hooks/exported/lintr.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@

"Run lintr on R files during a precommit.
Usage:
lintr [--warn_only] <files>...
lintr [--warn_only] [--root=<root_>] <files>...
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=<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)
Expand Down

0 comments on commit 10bd189

Please sign in to comment.