Skip to content

Commit 1310334

Browse files
committed
docs(README): typo, wording, comparision with husky
1 parent 2606f9b commit 1310334

2 files changed

Lines changed: 58 additions & 17 deletions

File tree

.changeset/wild-seas-swim.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@vnphanquang/githooks": patch
3+
---
4+
5+
docs: fix typo, wording, and add more detailed comparison vs `husky`

README.md

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,30 @@ Utility for setting up git hooks. A Deno port of [husky]
33
[![MIT][license.badge]][license] [![codecov][codecov.badge]][codecov] [![JSR][jsr.badge.package]][jsr.package] [![JSR][jsr.badge.score]][jsr.package]
44

55
> [!NOTE]
6-
> This library was written and tested in [Deno 2](https://deno.com/blog/v2.0), It has also been
6+
> This library was written in [Deno 2](https://deno.com/blog/v2.0),
77
> tested on Windows, MacOS, and Linux. See [code coverage](https://app.codecov.io/github/vnphanquang/githooks/flags?flags%5B0%5D=macos-latest&flags%5B1%5D=ubuntu-latest&flags%5B2%5D=windows-latest) for more information.
88
99
## Usage as CLI
1010

11-
1. Make sure your project is within a git directory
11+
1. Make sure your project is within a git directory...
1212

1313
```bash
14-
git init
14+
git init .
1515
```
1616

17-
2. Run initialization script:
17+
2. Run initialization script...
1818

1919
```bash
2020
deno run -A jsr:@vnphanquang/githooks/bin init
2121
```
2222

23-
> [!NOTE]
24-
> `init` will search up and run at the nearest git root directory, if any, or fail otherwise.
25-
26-
Alternatively, run with verbose permissions **at project root**:
23+
`init` will search up and run at the nearest git root directory, if any, or fail otherwise. Alternatively, run with verbose permissions **at project root**:
2724

2825
```bash
2926
deno run --allow-read="." --allow-write=".githooks" --allow-run="git" jsr:@vnphanquang/githooks/bin init
3027
```
3128

32-
3. Edit `./githooks/pre-commit` to your needs. Alternatively, you can create any git hook script by adding
33-
it to `.githooks/<your_hook>`. For example:
29+
3. Edit `./githooks/pre-commit` to your needs. You can create, edit, or remove any git hook script `.githooks/<your_hook>`. For example:
3430

3531
```bash
3632
#!/usr/bin/env sh
@@ -39,7 +35,7 @@ Utility for setting up git hooks. A Deno port of [husky]
3935
# file: .githooks/pre-push
4036
```
4137

42-
4. Optionally, add script as [deno task](https://docs.deno.com/runtime/reference/cli/task_runner/).
38+
4. Optionally, add script as [Deno task](https://docs.deno.com/runtime/reference/cli/task_runner/).
4339
See [Running as Deno Task](#automatic-initialization-for-fresh-repository) for more information.
4440

4541
## Usage as Library
@@ -56,7 +52,7 @@ await init(Deno.cwd());
5652

5753
### Running as Deno Task
5854

59-
It is helpful to save the script as a Deno task:
55+
It is helpful to save the script as a [Deno task](https://docs.deno.com/runtime/reference/cli/task_runner/):
6056

6157
```json
6258
{
@@ -81,11 +77,11 @@ For example, you can quickly add/update `pre-commit` by running:
8177
echo "npm test" > .githooks/pre-commit
8278
```
8379

84-
### (No) Automatic Initialization for Fresh Repository
80+
### (No) Automatic Initialization
8581

8682
Unlike Node, Deno does not support pre- or post- script pattern.
8783
Prefer to [use Deno task](#running-as-deno-task) and include
88-
explicit instruction for your team to run it after each `git clone`.
84+
explicit instruction for your team to run it after each `git clone` or upgrade.
8985

9086
### Usage with [lint-staged]
9187

@@ -98,6 +94,8 @@ deno run -A npm:lint-staged
9894
# file: .githooks/pre-commit
9995
```
10096

97+
As expected, this should look for any lint-staged config files at the project root. See [lint-staged configuration documentation](https://github.com/lint-staged/lint-staged?tab=readme-ov-file#configuration) for more information.
98+
10199
### Skipping Certain Hooks
102100

103101
If your git command supports `--no-verify`. You may skip running hooks by adding this flag.
@@ -154,11 +152,49 @@ scripts. Underneath, this run `set -x`.
154152
GITHOOKS=2 git commit -m "verbose run"
155153
```
156154

157-
## Prior Arts
155+
## Prior Arts & Acknowledgements
156+
157+
### Comparison and Benchmark vs [husky]
158+
159+
This project is greatly inspired by [husky]; it is even fair to say this is a direct Deno port of `huksy` . Credits should go to [@typicode](https://github.com/typicode). Please show support over there. In fact, today, you can use `husky` directly in Deno:
160+
161+
```bash
162+
deno run -A npm:husky
163+
```
164+
165+
This project builds upon ideas from `husky` while trying to stay minimal and only extend on some functionality that satisfies my personal needs. It is also an attempt to utilize Deno for more explicit permissions and idiomatic testing (`husky` uses `bash` for tests, which is totally fine but simply not my preference).
166+
167+
Regarding performance, both `npm:husky` and `jsr:@vnphanquang/githooks` are comparable, with `husky`
168+
being 1.02x to 1.05x faster, according to the benchmark of the `init` command run on my machine, as of #968d885:
169+
170+
```text
171+
CPU | Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz
172+
Runtime | Deno 2.0.2 (x86_64-unknown-linux-gnu)
173+
174+
benchmark time/iter (avg) iter/s (min … max) p75 p99 p995
175+
--------------------------- ----------------------------- --------------------- --------------------------
176+
group init
177+
npm:husky 5.3 ms 187.6 ( 5.0 ms … 14.7 ms) 5.3 ms 5.7 ms 14.7 ms
178+
jsr:@vnphanquang/githooks 5.4 ms 183.5 ( 5.2 ms … 5.9 ms) 5.5 ms 5.8 ms 5.9 ms
179+
180+
summary
181+
npm:husky
182+
1.02x faster than jsr:@vnphanquang/githooks
183+
```
184+
185+
You can try the benchmark yourself by cloning the repository and running:
186+
187+
```bash
188+
deno task bench
189+
```
190+
191+
### Similar Projects
158192

159-
This project is greatly inspired by [husky]; credits go to [@typicode](https://github.com/typicode). Please show support over there.
193+
Other projects with similar objective exists. Please show them some love too.
160194

161-
[Yakiyo/deno_hooks](https://github.com/Yakiyo/deno_hooks) is a similar project. Please show them some love too.
195+
- [Yakiyo/deno_hooks](https://github.com/Yakiyo/deno_hooks): also inspired by [husky], written in Deno 1; no tests have been implemented as of this writing.
196+
- [xCykrix/githooked](https://github.com/xCykrix/githooked): also inspired by [husky] but are likely
197+
no longer maintained or has been migrated away from Deno towards a standalone shell script.
162198

163199
[husky]: https://github.com/typicode/husky
164200
[deno]: https://deno.com/

0 commit comments

Comments
 (0)