Installations
npm install lefthook
Developer
evilmartians
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
18.20.5
NPM Version
10.8.2
Statistics
5,038 Stars
840 Commits
218 Forks
26 Watching
4 Branches
135 Contributors
Updated on 28 Nov 2024
Languages
Go (91.37%)
Ruby (3.98%)
JavaScript (2.06%)
Shell (1.25%)
Python (0.85%)
Makefile (0.49%)
Total Downloads
Cumulative downloads
Total Downloads
8,455,531
Last day
-10.7%
36,480
Compared to previous day
Last week
3.9%
208,755
Compared to previous week
Last month
11.8%
857,805
Compared to previous month
Last year
272.5%
6,549,041
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Lefthook
The fastest polyglot Git hooks manager out there
A Git hooks manager for Node.js, Ruby, Python 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.
- Simple. It is single dependency-free binary which can work in any environment.
📖 Read the introduction post
Install
With Go (>= 1.23):
1go install github.com/evilmartians/lefthook@latest
With NPM:
1npm install lefthook --save-dev
For Ruby:
1gem install lefthook
For Python:
1pip install lefthook
Installation guide with more ways to install lefthook: apt, brew, winget, and others.
Usage
Configure your hooks, install them once and forget about it: rely on the magic underneath.
TL;DR
1# Configure your hooks 2vim lefthook.yml 3 4# Install them to the git project 5lefthook install 6 7# Enjoy your work with git 8git add -A && git commit -m '...'
More details
- Configuration for
lefthook.yml
config options. - Usage for lefthook CLI options, supported ENVs, and usage tips.
- Discussions for questions, ideas, suggestions.
Why Lefthook
-
Parallel execution
Gives you more speed. Example
1pre-push: 2 parallel: true
-
Flexible list of files
If you want your own list. Custom and prebuilt examples.
1pre-commit: 2 commands: 3 frontend-linter: 4 run: yarn eslint {staged_files} 5 backend-linter: 6 run: bundle exec rubocop --force-exclusion {all_files} 7 frontend-style: 8 files: git diff --name-only HEAD @{push} 9 run: yarn stylelint {files}
-
Glob and regexp filters
If you want to filter list of files. You could find more glob pattern examples here.
1pre-commit: 2 commands: 3 backend-linter: 4 glob: "*.rb" # glob filter 5 exclude: '(^|/)(application|routes)\.rb$' # regexp filter 6 run: bundle exec rubocop --force-exclusion {all_files}
-
Execute in sub-directory
If you want to execute the commands in a relative path
1pre-commit: 2 commands: 3 backend-linter: 4 root: "api/" # Careful to have only trailing slash 5 glob: "*.rb" # glob filter 6 run: bundle exec rubocop {all_files}
-
Run scripts
If oneline commands are not enough, you can execute files. Example.
1commit-msg: 2 scripts: 3 "template_checker": 4 runner: bash
-
Tags
If you want to control a group of commands. Example.
1pre-push: 2 commands: 3 packages-audit: 4 tags: frontend security 5 run: yarn audit 6 gems-audit: 7 tags: backend security 8 run: bundle audit
-
Support Docker
If you are in the Docker environment. Example.
1pre-commit: 2 scripts: 3 "good_job.js": 4 runner: docker run -it --rm <container_id_or_name> {cmd}
-
Local config
If you a frontend/backend developer and want to skip unnecessary commands or override something into Docker. Description.
1# lefthook-local.yml 2pre-push: 3 exclude_tags: 4 - frontend 5 commands: 6 packages-audit: 7 skip: true
-
Direct control
If you want to run hooks group directly.
1$ lefthook run pre-commit
-
Your own tasks
If you want to run specific group of commands directly.
1fixer: 2 commands: 3 ruby-fixer: 4 run: bundle exec rubocop --force-exclusion --safe-auto-correct {staged_files} 5 js-fixer: 6 run: yarn eslint --fix {staged_files}
1$ lefthook run fixer
-
Optional output
If you don't want to see supporting information:
1skip_output: 2 - meta #(version and which hook running) 3 - success #(output from runners with exit code 0)
Guides
- Install with Node.js
- Install with Ruby
- Install with Homebrew
- Install with Winget
- Install for Debian-based Linux
- Install for RPM-based Linux
- Install for Arch Linux
- Usage
- Configuration
Examples
Articles
- 5 cool (and surprising) ways to configure Lefthook for automation joy
- Lefthook: Knock your team’s code back into shape
- Lefthook + Crystalball
- Keeping OSS documentation in check with docsify, Lefthook, and friends
- Automatically linting docker containers
- Smooth PostgreSQL upgrades in DockerDev environments with Lefthook
- Lefthook for React/React Native apps
No vulnerabilities found.
Reason
30 commit(s) and 22 issue activity found in the last 90 days -- score normalized to 10
Reason
no dangerous workflow patterns detected
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
packaging workflow detected
Details
- Info: Project packages its releases by way of GitHub Actions.: .github/workflows/release.yml:12
Reason
SAST tool is run on all commits
Details
- Info: SAST configuration detected: CodeQL
- Info: all commits (20) are checked with a SAST tool
Reason
Found 5/30 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'actions' permission set to 'read': .github/workflows/codeql.yml:18
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/codeql.yml:19
- Warn: no topLevel permission defined: .github/workflows/codeql.yml:1
- Warn: no topLevel permission defined: .github/workflows/lint.yml:1
- Warn: topLevel 'contents' permission set to 'write': .github/workflows/release.yml:9
- Warn: no topLevel permission defined: .github/workflows/test.yml:1
- Info: no jobLevel write permissions found
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/codeql.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/codeql.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/codeql.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:62: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/codeql.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/lint.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/lint.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/lint.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/lint.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:57: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:62: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:83: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:88: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:111: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:116: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/release.yml:122: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:151: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:161: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:49: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:58: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:69: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:75: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:83: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:94: update your workflow using https://app.stepsecurity.io/secureworkflow/evilmartians/lefthook/test.yml/master?enable=pin
- Warn: pipCommand not pinned by hash: .github/workflows/release.yml:126
- Info: 0 out of 23 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 10 third-party GitHubAction dependencies pinned
- Info: 0 out of 1 pipCommand dependencies pinned
- Info: 1 out of 1 goCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
Project has not signed or included provenance with any releases.
Details
- Warn: release artifact v1.8.4 not signed: https://api.github.com/repos/evilmartians/lefthook/releases/185890388
- Warn: release artifact v1.8.3 not signed: https://api.github.com/repos/evilmartians/lefthook/releases/185884649
- Warn: release artifact v1.8.2 not signed: https://api.github.com/repos/evilmartians/lefthook/releases/182406532
- Warn: release artifact v1.8.1 not signed: https://api.github.com/repos/evilmartians/lefthook/releases/181390123
- Warn: release artifact v1.8.0 not signed: https://api.github.com/repos/evilmartians/lefthook/releases/181169839
- Warn: release artifact v1.8.4 does not have provenance: https://api.github.com/repos/evilmartians/lefthook/releases/185890388
- Warn: release artifact v1.8.3 does not have provenance: https://api.github.com/repos/evilmartians/lefthook/releases/185884649
- Warn: release artifact v1.8.2 does not have provenance: https://api.github.com/repos/evilmartians/lefthook/releases/182406532
- Warn: release artifact v1.8.1 does not have provenance: https://api.github.com/repos/evilmartians/lefthook/releases/181390123
- Warn: release artifact v1.8.0 does not have provenance: https://api.github.com/repos/evilmartians/lefthook/releases/181169839
Score
5.5
/10
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to lefthook
lefthook-linux-x64
The Linux 64-bit binary for lefthook, git hooks manager.
lefthook-freebsd-x64
The FreeBSD 64-bit binary for lefthook, git hooks manager.
lefthook-freebsd-arm64
The FreeBSD ARM 64-bit binary for lefthook, git hooks manager.
lefthook-openbsd-x64
The OpenBSD 64-bit binary for lefthook, git hooks manager.