Skip to content

Commit

Permalink
docs: update docs and readme with tl;dr instructions (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexox authored Sep 13, 2023
1 parent 08a56d3 commit af2fb23
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 10 deletions.
29 changes: 21 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<img align="right" width="147" height="100" title="Lefthook logo"
src="./logo_sign.svg">

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.
Expand Down Expand Up @@ -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.

***

Expand Down
22 changes: 21 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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.
Expand Down
9 changes: 8 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit af2fb23

Please sign in to comment.