You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Files array is computed by running a files command from working directory. But run is run from filepath.Join(r.repo.RootPath, command.Root). This makes a weird looking configuration in case of using custom scripts for both options:
# consider nested packages/test/lefthook.ymlpre-push:
commands:
eslint:
root: 'packages/test/'files: scripts/get-files-push # this is relative to working directory (repo root)run: ../../scripts/lint-fix eslint {files} # this is relative to packages/test
In my opinion files should also be computed based on root path.
Love lefthook!! I just dove in a day or so ago. This was the only real pain point for me. We have a CRA app in client directory and server node code in the root level folders. Below is the run command I came up with to fix the paths by removing the root level of the path. If someone needs this but deeper into the directory structure adjust the cut -d'/' -f2- part to make the number be +1 of how many directories to lop off.
run: fixedFiles=$(for staged_file in ${staged_files}; do echo $(echo $staged_file | cut -d'/' -f2-); done;); cd client; prettier --ignore-unknown --write $fixedFiles && eslint --max-warnings 0 $fixedFiles && git add $fixedFiles
Unrelated but thought I'd share this idea while I'm here. I made a post-merge action that globs on lefthook.yml to trigger lefthook install. This way new developers work out of the box after npm i from a fresh clone and existing developers will be kept up to date as the config evolves.
only other minor feedback is occasionally it spits characters out into my terminal after running npm exec lefthook run pre-commit. Not very consistent so repro is difficult of course. Anyways, thanks for this contribution and plus one to this feature request.
Files array is computed by running a
files
command from working directory. Butrun
is run fromfilepath.Join(r.repo.RootPath, command.Root)
. This makes a weird looking configuration in case of using custom scripts for both options:In my opinion
files
should also be computed based onroot
path.Source code:
lefthook/internal/git/repository.go
Lines 88 to 93 in f3ffc5b
lefthook/internal/lefthook/runner/runner.go
Lines 191 to 192 in 3e6c8ec
The text was updated successfully, but these errors were encountered: