-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
392 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,40 @@ | ||
## Git hook | ||
|
||
Contains settings for the git hook (commands, scripts, skip rules, etc.). You can specify any Git hook or your own custom, e.g. `test` | ||
|
||
### Hook options | ||
|
||
- [`files`](./files-global.md) | ||
- [`parallel`](./parallel.md) | ||
- [`piped`](./piped.md) | ||
- [`follow`](./follow.md) | ||
- [`exclude_tags`](./exclude_tags.md) | ||
- [`skip`](./skip.md) | ||
- [`only`](./only.md) | ||
- [`commands`](./Commands.md) | ||
- [`run`](./run.md) | ||
- [`skip`](./skip.md) | ||
- [`only`](./only.md) | ||
- [`tags`](./tags.md) | ||
- [`glob`](./glob.md) | ||
- [`files`](./files.md) | ||
- [`file_types`](./file_types.md) | ||
- [`env`](./env.md) | ||
- [`root`](./root.md) | ||
- [`exclude`](./exclude.md) | ||
- [`fail_text`](./fail_text.md) | ||
- [`stage_fixed`](./stage_fixed.md) | ||
- [`interactive`](./interactive.md) | ||
- [`use_stdin`](./use_stdin.md) | ||
- [`priority`](./priority.md) | ||
- [`scripts`](./Scripts.md) | ||
- [`runner`](./runner.md) | ||
- [`skip`](./skip.md) | ||
- [`only`](./only.md) | ||
- [`tags`](./tags.md) | ||
- [`env`](./env.md) | ||
- [`fail_text`](./fail_text.md) | ||
- [`stage_fixed`](./stage_fixed.md) | ||
- [`interactive`](./interactive.md) | ||
- [`use_stdin`](./use_stdin.md) | ||
- [`priority`](./priority.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,28 @@ | ||
# Usage | ||
|
||
- [Commands](./usage/commands.md) | ||
- [`lefthook install`](./usage/commands.md#lefthook-install) | ||
- [`lefthook uninstall`](./usage/commands.md#lefthook-uninstall) | ||
- [`lefthook add`](./usage/commands.md#lefthook-add) | ||
- [`lefthook run`](./usage/commands.md#lefthook-run) | ||
- [`lefthook version`](./usage/commands.md#lefthook-version) | ||
- [`lefthook self-update`](./usage/commands.md#lefthook-self-update) | ||
- [ENV variables](./usage/env.md) | ||
- [`LEFTHOOK`](./usage/env.md#lefthook) | ||
- [`LEFTHOOK_EXCLUDE`](./usage/env.md#lefthook_exclude) | ||
- [`LEFTHOOK_OUTPUT`](./usage/env.md#lefthook_output) | ||
- [`LEFTHOOK_QUIET`](./usage/env.md#lefthook_quiet) | ||
- [`LEFTHOOK_VERBOSE`](./usage/env.md#lefthook_verbose) | ||
- [`LEFTHOOK_BIN`](./usage/env.md#lefthook_bin) | ||
- [`NO_COLOR`](./usage/env.md#no_color) | ||
- [`CLICOLOR_FORCE`](./usage/env.md#clicolor_force) | ||
- [Tips](./usage/tips.md) | ||
- [Local config](./usage/tips.md#local-config) | ||
- [Disable lefthook in CI](./usage/tips.md#disable-lefthook-in-ci) | ||
- [Commitlint example](./usage/tips.md#commitlint-example) | ||
- [Parallel execution](./usage/tips.md#parallel-execution) | ||
- [Concurrent files overrides](./usage/tips.md#concurrent-files-overrides) | ||
- [Capture ARGS from git in the script](./usage/tips.md#capture-args-from-git-in-the-script) | ||
- [Git LFS support](./usage/tips.md#git-lfs-support) | ||
- [Pass stdin to a command or script](./usage/tips.md#pass-stdin-to-a-command-or-script) | ||
- [Using an interactive command or script](./usage/tips.md#using-an-interactive-command-or-script) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
## Commands | ||
|
||
Use `lefthook help` or `lefthook <command> -h/--help` to discover available commands and their options. | ||
|
||
### `lefthook install` | ||
|
||
`lefthook install` creates an empty `lefthook.yml` if a configuration file does not exist and updates git hooks to use lefthook. Run `lefthook install` after cloning the git repo. | ||
|
||
> NOTE | ||
> | ||
> NPM package `lefthook` installs the hooks in a postinstall script automatically. | ||
### `lefthook uninstall` | ||
|
||
`lefthook uninstall` clears git hooks affected by lefthook. If you have lefthook installed as an NPM package you should remove it manually. | ||
|
||
### `lefthook add` | ||
|
||
`lefthook add pre-commit` will create a file `.git/hooks/pre-commit`. This is the same lefthook does for [`install`](#lefthook-install) command but you don't need to create a configuration first. | ||
|
||
To use custom scripts as hooks create the required directories with `lefthook add pre-commit --dirs`. | ||
|
||
**Example** | ||
|
||
```bash | ||
$ lefthook add pre-push --dirs | ||
``` | ||
|
||
Describe pre-push commands in `lefthook.yml`: | ||
|
||
```yml | ||
pre-push: | ||
scripts: | ||
"audit.sh": | ||
runner: bash | ||
``` | ||
Edit the script: | ||
```bash | ||
$ vim .lefthook/pre-push/audit.sh | ||
... | ||
``` | ||
|
||
Run `git push` and lefthook will run `bash audit.sh` as a pre-push hook. | ||
|
||
### `lefthook run` | ||
|
||
`lefthook run` executes the commands and scripts configured for a given hook. Generated hooks call `lefthook run` implicitly. | ||
|
||
**Example** | ||
|
||
```yml | ||
# lefthook.yml | ||
|
||
pre-commit: | ||
commands: | ||
lint: | ||
run: yarn lint --fix | ||
|
||
test: | ||
commands: | ||
js-test: | ||
run: yarn test | ||
``` | ||
Install the hook. | ||
```bash | ||
$ lefthook install | ||
``` | ||
|
||
Run `test`. | ||
|
||
```bash | ||
$ lefthook run test # will run 'yarn test' | ||
``` | ||
|
||
Commit changes. | ||
|
||
```bash | ||
$ git commit # will run pre-commit hook ('yarn lint --fix') | ||
``` | ||
|
||
Or run manually also | ||
|
||
```bash | ||
$ lefthook run pre-commit | ||
``` | ||
|
||
You can also specify a flag to run only some commands: | ||
|
||
```bash | ||
$ lefthook run pre-commit --commands lint | ||
``` | ||
|
||
and optionally run either on all files (any `{staged_files}` placeholder acts as `{all_files}`) or a list of files: | ||
|
||
```bash | ||
$ lefthook run pre-commit --all-files | ||
$ lefthook run pre-commit --file file1.js --file file2.js | ||
``` | ||
|
||
(if both are specified, `--all-files` is ignored) | ||
|
||
### `lefthook version` | ||
|
||
`lefthook version` prints the current binary version. Print the commit hash with `lefthook version --full` | ||
|
||
**Example** | ||
|
||
```bash | ||
$ lefthook version --full | ||
|
||
1.1.3 bb099d13c24114d2859815d9d23671a32932ffe2 | ||
``` | ||
|
||
### `lefthook self-update` | ||
|
||
`lefthook self-update` updates the binary with the latest lefthook release on Github. This command is available only if you install lefthook from sources or download the binary from the Github Releases. For other ways use package-specific commands to update lefthook. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
## ENV variables | ||
|
||
### `LEFTHOOK` | ||
|
||
Use `LEFTHOOK=0 git ...` or `LEFTHOOK=false git ...` to disable lefthook when running git commands. | ||
|
||
**Example** | ||
|
||
```bash | ||
LEFTHOOK=0 git commit -am "Lefthook skipped" | ||
``` | ||
|
||
### `LEFTHOOK_EXCLUDE` | ||
|
||
Use `LEFTHOOK_EXCLUDE={list of tags or command names to be excluded}` to skip some commands or scripts by tag or name (for commands only). See the [`exclude_tags`](../configuration/exclude_tags.md) configuration option for more details. | ||
|
||
**Example** | ||
|
||
```bash | ||
LEFTHOOK_EXCLUDE=ruby,security,lint git commit -am "Skip some tag checks" | ||
``` | ||
|
||
### `LEFTHOOK_OUTPUT` | ||
|
||
Use `LEFTHOOK_OUTPUT={list of output values}` to specify what to print in your output. You can also set `LEFTHOOK_OUTPUT=false` to disable all output except for errors. Refer to the [`output`](../configuration/output.md) configuration option for more details. | ||
|
||
**Example** | ||
|
||
```bash | ||
$ LEFTHOOK_OUTPUT=summary lefthook run pre-commit | ||
summary: (done in 0.52 seconds) | ||
✔️ lint | ||
``` | ||
|
||
### `LEFTHOOK_QUIET` | ||
|
||
You can skip some outputs printed by lefthook by setting the `LEFTHOOK_QUIET` environment variable. Provide a list of output types to be skipped. See the [`skip_output`](../configuration/skip_output.md) configuration option for more details. | ||
|
||
**Example** | ||
|
||
```bash | ||
$ LEFTHOOK_QUIET=meta,execution lefthook run pre-commit | ||
|
||
EXECUTE > lint | ||
|
||
SUMMARY: (done in 0.01 seconds) | ||
🥊 lint | ||
``` | ||
|
||
### `LEFTHOOK_VERBOSE` | ||
|
||
Set `LEFTHOOK_VERBOSE=1` or `LEFTHOOK_VERBOSE=true` to enable verbose printing. | ||
|
||
### `LEFTHOOK_BIN` | ||
|
||
Set `LEFTHOOK_BIN` to a location where lefthook is installed to use that instead of trying to detect from the it the PATH or from a package manager. | ||
|
||
Useful for cases when: | ||
|
||
- lefthook is installed multiple ways, and you want to be explicit about which one is used (example: installed through homebrew, but also is in Gemfile but you are using a ruby version manager like rbenv that prepends it to the path) | ||
- debugging and/or developing lefthook | ||
|
||
### `NO_COLOR` | ||
|
||
Set `NO_COLOR=true` to disable colored output in lefthook and all subcommands that lefthook calls. | ||
|
||
### `CLICOLOR_FORCE` | ||
|
||
Set `CLICOLOR_FORCE=true` to force colored output in lefthook and all subcommands. | ||
|
Oops, something went wrong.