diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..fb9a1fe --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,18 @@ +- id: lychee + name: lychee + description: "Run 'lychee' for fast, async, stream-based link checking" + entry: lychee + language: system + args: ["--no-progress"] + types: [text] + pass_filenames: true + require_serial: true +- id: lychee-docker + name: lychee + description: "Run 'lychee' docker image for fast, async, stream-based link checking" + entry: lycheeverse/lychee:0.14 + language: docker_image + args: ["--no-progress"] + types: [text] + pass_filenames: true + require_serial: true diff --git a/README.md b/README.md index 2c4101a..82af6ac 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Available as a command-line utility, a library and a [GitHub Action](https://git - [Commandline usage](#commandline-usage) - [Library usage](#library-usage) - [GitHub Action Usage](#github-action-usage) +- [Pre-commit Usage](#pre-commit-usage) - [Contributing to lychee](#contributing-to-lychee) - [Debugging and improving async code](#debugging-and-improving-async-code) - [Troubleshooting and Workarounds](#troubleshooting-and-workarounds) @@ -551,6 +552,27 @@ folder. A GitHub Action that uses lychee is available as a separate repository: [lycheeverse/lychee-action](https://github.com/lycheeverse/lychee-action) which includes usage instructions. +## Pre-commit Usage + +Lychee can also be used as a [pre-commit](https://pre-commit.com/) hook. +```yaml +# .pre-commit-config.yaml +repos: + - repo: https://github.com/lycheeverse/lychee.git + rev: 0.14.3 + hooks: + - id: lychee + # Optionally include additional CLI arguments + args: ["--no-progress", "--exclude", "file://"] +``` + +Rather than running on staged-files only, Lychee can be run against an entire repository. +```yaml +- id: lychee + args: ["--no-progress", "."] + pass_filenames: false +``` + ## Contributing to lychee We'd be thankful for any contribution. \