Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document the unusual behaviour of ** in glob option
I had assumed that glob patterns work like they do with the *nix `ls` command, or in tools like lint-staged. It seems that ** is interpreted as a single asterisk for 1+ directories, rather than "0 or more directories deep" as in `ls`. Whilst there is a link to the Go glob library used, and it mentions double asterisks, I was mainly left confused by the line in the README: > Syntax is inspired by [standard > wildcards](http://tldp.org/LDP/GNU-Linux-Tools-Summary/html/x11655.htm), > except that ** is aka super-asterisk, that do not sensitive for separators. Whilst the glob library README could be improved, I think it's natural to use `ls` to try and test what would be matched (or copy config from tools like lint-staged or pre-commit), so it would be great to call out this difference in the lefthook documentation. It might be quite useful to provide a means of testing/listing what files would be matched for different commands - I found it necessary to do the below. Example ======= Let's say you have a directory structure like: ``` - src - foo - bar - nestedTwice.js - nestedOnce.js - topLevel.js ``` If you run `ls -1`, you get all three files: ``` ls -1 src/**/*.js src/foo/bar/nestedTwice.js src/foo/nestedOnce.js src/topLevel.js ``` Given this lefthook config ```yaml pre-commit: commands: eslint: run: ls -1 {staged_files} glob: "src/**/*.js" ``` And you run: ```sh git add src lefthook run pre-commit ``` The output is missing `src/topLevel.js`: ``` src/foo/bar/nestedTwice.js src/foo/nestedOnce.js ```
- Loading branch information