I have created a virtual environment with rvenv, so that I now have rvenv/
in my project root. I have also installed styler
, and would like to have a pre-commit hook that will apply it to R code.
From here: https://github.com/lorenzwalthert/precommit/blob/master/.pre-commit-hooks.yaml is the following:
- id: style-files
name: style-files
description: style files with styler
args: [--style_pkg=styler, '--style_transformers=tidyverse_style(scope = "tokens")']
entry: inst/bin/style-files
language: script
files: '(\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$'
I'm confused about the path that should be given to entry:
, in this snip it's a path to a global version of styler
(or at least, I'm assuming so). But I would like to be able to use the version that I have installed in the virtual environment I assume.
My question is - how to go about doing this. If I shouldn't be using the version installed in renv/
then I'm happy to hear (and use) whatever the best practice is around creating a pre-commit hook to style R files that will work on mine and others systems.
Edit
Following the answer below worked, I had to install docopt as well (as outlined here).