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.6
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.7
Choose a head ref
  • 4 commits
  • 6 files changed
  • 1 contributor

Commits on Jan 25, 2024

  1. style: indent

    typicode committed Jan 25, 2024
    Copy the full SHA
    c1bbd9b View commit details

Commits on Jan 26, 2024

  1. docs: fix example (#1363)

    * docs: fix example
    
    * add log
    typicode authored Jan 26, 2024
    2
    Copy the full SHA
    800fbf1 View commit details

Commits on Jan 29, 2024

  1. Copy the full SHA
    04d7407 View commit details
  2. chrore: bump version

    typicode authored Jan 29, 2024
    Copy the full SHA
    9e08ef0 View commit details
Showing with 18 additions and 19 deletions.
  1. +9 −9 bin.js
  2. +4 −5 docs/how-to.md
  3. +2 −2 husky.sh
  4. +1 −1 index.d.ts
  5. +1 −1 index.js
  6. +1 −1 package.json
18 changes: 9 additions & 9 deletions bin.js
Original file line number Diff line number Diff line change
@@ -5,18 +5,18 @@ import i from './index.js'
let a = process.argv[2]

if (a == 'init') {
let p = 'package.json'
let d = JSON.parse(f.readFileSync(p))
;(d.scripts ||= {}).prepare = 'husky'
w('package.json', JSON.stringify(d, null, /\t/.test() ? '\t' : 2) + '\n')
process.stdout.write(i())
try { f.mkdirSync('.husky') } catch {}
w('.husky/pre-commit', process.env.npm_config_user_agent.split('/')[0] + ' test\n')
process.exit()
let p = 'package.json'
let d = JSON.parse(f.readFileSync(p))
; (d.scripts ||= {}).prepare = 'husky'
w('package.json', JSON.stringify(d, null, /\t/.test() ? '\t' : 2) + '\n')
process.stdout.write(i())
try { f.mkdirSync('.husky') } catch { }
w('.husky/pre-commit', process.env.npm_config_user_agent.split('/')[0] + ' test\n')
process.exit()
}

let d = c => console.error(`${c} command is deprecated`)
if (['add', 'set', 'uninstall'].includes(a)) { d(a); process.exit(1) }
if (a == 'install') d(a)

process.stdout.write(i(a == 'install' ? undefined : a))
process.stdout.write(i(a == 'install' ? undefined : a))
9 changes: 4 additions & 5 deletions docs/how-to.md
Original file line number Diff line number Diff line change
@@ -68,14 +68,13 @@ Modify the `prepare` script to never fail:

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`:

<!-- Since husky may not be installed, it must be imported dynamically after prod/CI check -->
```js
// Skip Husky install in production and CI
import husky from 'husky'
if (process.env.NODE_ENV === 'production' || process.env.CI === '1') {
if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') {
process.exit(0)
}
const husky = (await import('husky')).default
console.log(husky())
```

@@ -190,7 +189,7 @@ Alternatively, if your shell startup file is fast and lightweight, source it dir

## Manual setup

Git needs to be configured and husky needs to setup files in `.husky/`.
Git needs to be configured and husky needs to setup files in `.husky/`.

Run the `husky` command once in your repo. Ideally, include it in the `prepare` script in `package.json` for automatic execution after each install (recommended).

4 changes: 2 additions & 2 deletions husky.sh
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ s="${0%/*/*}/$h"

[ ! -f "$s" ] && exit 0

for f in "${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh" "$HOME/.huskyrc.sh"; do
for f in "${XDG_CONFIG_HOME:-$HOME/.config}/husky/init.sh" "$HOME/.huskyrc"; do
# shellcheck disable=SC1090
[ -f "$f" ] && . "$f"
done
@@ -18,4 +18,4 @@ c=$?

[ $c != 0 ] && echo "husky - $h script failed (code $c)"
[ $c = 127 ] && echo "husky - command not found in PATH=$PATH"
exit $c
exit $c
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default function (dir?: string): string;
export default function (dir?: string): string;
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -20,4 +20,4 @@ export default (d = '.husky') => {
l.forEach(h => w(_(h), `#!/usr/bin/env sh\n. "\${0%/*}/h"`, { mode: 0o755 }))
w(_('husky.sh'), '')
return ''
}
}
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.6",
"version": "9.0.7",
"description": "Modern native Git hooks",
"keywords": [
"git",