Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: typicode/husky
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v9.0.5
Choose a base ref
...
head repository: typicode/husky
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v9.0.6
Choose a head ref
  • 5 commits
  • 6 files changed
  • 3 contributors

Commits on Jan 25, 2024

  1. docs: add favicon (#1354)

    rakleed authored Jan 25, 2024
    Copy the full SHA
    f446351 View commit details
  2. chore: apply editorconfig to code only (#1355)

    * chore: apply editorconfig to code only
    
    * Update file extensions in .editorconfig
    typicode authored Jan 25, 2024
    Copy the full SHA
    534bfed View commit details
  3. docs: update install script to mjs and simplify (#1357)

    * docs: update install script to mjs and fix CI checks
    
    * revert indent
    
    * Update how-to.md
    
    ---------
    
    Co-authored-by: typicode <typicode@gmail.com>
    starnayuta and typicode authored Jan 25, 2024
    1
    Copy the full SHA
    e7ada20 View commit details
  4. Fix: unbound variable (#1359)

    * fix: unbound variable
    
    * fix: unbound variable
    typicode authored Jan 25, 2024
    Copy the full SHA
    797dfdf View commit details
  5. 9.0.6

    typicode committed Jan 25, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    2da78cb View commit details
Showing with 16 additions and 10 deletions.
  1. +1 −1 .editorconfig
  2. +3 −0 docs/.vitepress/config.mts
  3. +6 −4 docs/how-to.md
  4. +3 −2 husky.sh
  5. +2 −2 package-lock.json
  6. +1 −1 package.json
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
root = true
[*]
[*.{json,js,ts,sh}]
end_of_line = lf
indent_style = tab
insert_final_newline = false
3 changes: 3 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
@@ -4,6 +4,9 @@ import { defineConfig } from 'vitepress'
export default defineConfig({
title: "Husky",
description: "Git hooks made easy",
head: [
['link', { rel: 'icon', href: 'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text y=".9em" font-size="85">🐶</text></svg>' }],
],
base: '/husky/',
themeConfig: {
// outline: [2, 3],
10 changes: 6 additions & 4 deletions docs/how-to.md
Original file line number Diff line number Diff line change
@@ -66,21 +66,23 @@ Modify the `prepare` script to never fail:
"prepare": "husky || true"
```

You'll still get a `command not found` error message in your output which may be confusing. To make it silent, create `.husky/install.js`:
You'll still get a `command not found` error message in your output which may be confusing. To make it silent, create `.husky/install.mjs`:

```js
// Skip Husky install in production and CI
import husky from 'husky'
if (process.env.NODE_ENV === 'production' || process.env.CI === '1') {
process.exit(0)
}
const husky = await import('husky')
husky()
console.log(husky())
```

Then, use it in `prepare`:

```json
"prepare": "node .husky/install.js"
"prepare": "node .husky/install.mjs"
```

## Testing Hooks Without Committing
5 changes: 3 additions & 2 deletions husky.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env sh
[ "$HUSKY" = "2" ] && set -x
H="$HUSKY"
[ "$H" = "2" ] && set -x
h="${0##*/}"
s="${0%/*/*}/$h"

@@ -10,7 +11,7 @@ for f in "${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh" "$HOME/.huskyrc.sh";
[ -f "$f" ] && . "$f"
done

[ "$HUSKY" = "0" ] && exit 0
[ "$H" = "0" ] && exit 0

sh -e "$s" "$@"
c=$?
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "husky",
"version": "9.0.5",
"version": "9.0.6",
"description": "Modern native Git hooks",
"keywords": [
"git",