diff --git a/README.md b/README.md index 2d2a5ce4..5f7733ce 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ -Fast and powerful Git hooks manager for Node.js, Ruby or any other type of projects. +A Git hooks manager for Node.js, Ruby and many other types of projects. * **Fast.** It is written in Go. Can run commands in parallel. * **Powerful.** It allows to control execution and files you pass to your commands. @@ -39,18 +39,31 @@ With **Ruby**: gem install lefthook ``` -**[Installation guide](./docs/install.md)** with more different installation instructions. +**[Installation guide](./docs/install.md)** with more ways to install lefthook: [apt](./docs/install.md#deb), [brew](./docs/install.md#homebrew), [winget](./docs/install.md#winget), and others. ## Usage -Lefthook is easy to use. Once you configure and setup you can forget that it even exists and rely on the magic underneath. +Configure your hooks, install them once and forget about it: rely on the magic underneath. -See: +#### TL;DR -- [**Usage**](./docs/usage.md) of **lefthook** CLI utility. -- [**Configuration**](./docs/configuration.md) details for `lefthook.yml` -- [**Wiki**](https://github.com/evilmartians/lefthook/wiki) for other information. -- [**Discussions**](https://github.com/evilmartians/lefthook/discussions) if you want to ask a question, suggest a feature, or report a bug. +```bash +# Configure your hooks +vim lefthook.yml + +# Install them to the git project +lefthook install + +# Enjoy your work with git +git add -A && git commit -m '...' +``` + +#### More details + +- [**Configuration**](./docs/configuration.md) for `lefthook.yml` config options. +- [**Usage**](./docs/usage.md) for **lefthook** CLI options, supported ENVs, and usage tips. +- [**Wiki**](https://github.com/evilmartians/lefthook/wiki) for guides, examples, and benchmarks. +- [**Discussions**](https://github.com/evilmartians/lefthook/discussions) for questions, ideas, suggestions. *** diff --git a/docs/configuration.md b/docs/configuration.md index 9929d473..282ed103 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -1,5 +1,8 @@ -# Configure lefthook.yml +# Configure lefthook +Lefthook [supports](#config-file) YAML, JSON, and TOML configuration. In this document `lefthook.yml` is used for simplicity. + +- [Config file](#config-file) - [Top level options](#top-level-options) - [`assert_lefthook_installed`](#assert_lefthook_installed) - [`colors`](#colors) @@ -58,6 +61,23 @@ ---- +## Config file + +Lefthook supports the following file names for the main config: + +- `lefthook.yml` +- `.lefthook.yml` +- `lefthook.yaml` +- `.lefthook.yaml` +- `lefthook.toml` +- `.lefthook.toml` +- `lefthook.json` +- `.lefthook.json` + +If there are more than 1 file in the project, only one will be used, and you'll never know which one. So, please, use one format in a project. + +Lefthook also merges an extra config with the name `lefthook-local`. All supported formats can be applied to this `-local` config. If you name your main config with the leading dot, like `.lefthook.json`, the `-local` config also must be named with the leading dot: `.lefthook-local.json`. + ## Top level options These options are not related to git hooks, and they only control lefthook behavior. diff --git a/docs/usage.md b/docs/usage.md index f5a87706..fcfae0e1 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -1,5 +1,12 @@ # Usage +You want to use lefthook in your git project. Here is what you need: + +1. Create a `lefthook.yml` (or use any other [supported name](./configuration.md#config-file)) +1. [Install](#lefthook-install) lefthook git hooks + +Then use git as usually, you don't need to reinstall lefthook when you change the config. + - [Commands](#commands) - [`lefthook install`](#lefthook-install) - [`lefthook uninstall`](#lefthook-uninstall) @@ -32,7 +39,7 @@ Here are the description of common usage of these commands. ### `lefthook install` -Run `lefthook install` to initialize a `lefthook.yml` config and/or synchronize `.git/hooks/` with your configuration. This is usually the first thing you do after cloning the repo with `lefthook.yml` config. For config options see our [configuration documentation](./configuration.md). +Run `lefthook install` to initialize a `lefthook.yml` config and/or synchronize `.git/hooks/` with your configuration. This must be the first thing you do after cloning the repo with `lefthook.yml` config. For config options see our [configuration documentation](./configuration.md). > If you use lefthook with NPM package manager it should have already run `lefthook install` in postinstall scripts.