Skip to content

Commit 10bd189

Browse files
committed
feat: add --root argument to lintr hook
1 parent 9525a2e commit 10bd189

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

inst/hooks/exported/lintr.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33

44
"Run lintr on R files during a precommit.
55
Usage:
6-
lintr [--warn_only] <files>...
6+
lintr [--warn_only] [--root=<root_>] <files>...
77
Options:
88
--warn_only Print lint warnings instead of blocking the commit. Should be
99
used with `verbose: True` in `.pre-commit-config.yaml`.
1010
Otherwise, lints will never be shown to the user.
11+
--root=<root_> Path relative to the git root that contains the R package root [default: .].
1112
" -> doc
1213

1314
arguments <- precommit::precommit_docopt(doc)
15+
arguments$files <- normalizePath(arguments$files) # because working directory changes to root
16+
setwd(normalizePath(arguments$root))
1417

1518
lintr_staged <- grepl(
1619
"modified:.*\\.lintr", system2("git", "status", stdout = TRUE)

0 commit comments

Comments
 (0)