
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
simple-git-hooks
Advanced tools
A simple, zero dependency tool for setting up git hooks for small projects
The simple-git-hooks npm package is designed to manage Git hooks in a straightforward and efficient manner. It allows you to easily configure and manage Git hooks using a simple configuration file, making it easier to enforce code quality and automate tasks in your development workflow.
Setup Git Hooks
This feature allows you to set up Git hooks by adding a configuration to your package.json file. The example shows how to run tests before committing and linting before pushing changes.
json
{
"scripts": {
"postinstall": "simple-git-hooks"
},
"simple-git-hooks": {
"pre-commit": "npm test",
"pre-push": "npm run lint"
}
}
Custom Hook Scripts
You can specify custom scripts to be executed for different Git hooks. In this example, custom shell scripts are specified for the pre-commit and pre-push hooks.
json
{
"simple-git-hooks": {
"pre-commit": "./scripts/pre-commit.sh",
"pre-push": "./scripts/pre-push.sh"
}
}
Husky is a popular package for managing Git hooks. It offers more advanced features and flexibility compared to simple-git-hooks, such as the ability to run hooks conditionally and support for monorepos. However, it can be more complex to set up and configure.
Lefthook is another tool for managing Git hooks, focusing on speed and performance. It supports parallel execution of hooks and is designed to work well in large repositories. Lefthook provides a more performant alternative to simple-git-hooks but may require more initial setup.
Pre-commit is a framework for managing and maintaining multi-language pre-commit hooks. It is highly configurable and supports a wide range of hooks out of the box. Pre-commit is more feature-rich and versatile compared to simple-git-hooks, but it can be more complex to configure.
A tool that lets you easily manage git hooks
The package was recently renamed from
simple-pre-commit
. See Releases for thesimple-pre-commit
documentation.
Install simple-git-hooks as a dev dependency:
npm install simple-git-hooks --save-dev
Add simple-git-hooks
to your package.json
. Fill it with git hooks and the corresponding commands.
For example:
"simple-git-hooks": {
"pre-commit": "npx lint-staged",
"pre-push": "cd ../../ && npm run format"
}
This configuration is going to run all linters on every commit
and formatter on push
.
There are more ways to configure the package. Check out Additional configuration options.
Run the CLI script to update the git hooks with the commands from the config:
npx simple-git-hooks
Now all the git hooks are created.
Change the configuration.
Run npx simple-git-hooks
from the root of your project.
Note that you should manually run npx simple-git-hooks
every time you change a command.
You can also add a .simple-git-hooks.json
or simple-git-hooks.json
file to the project and write the configuration inside it.
That way, .simple-git-hooks.json
or simple-git-hooks.json
should look like the following and package.json
may not contain the simple-git-hooks
configuration.
{
"pre-commit": "npx lint staged",
"pre-push": "cd ../../ && npm run format"
}
Uninstallation will remove all the existing git hooks.
npm uninstall simple-git-hooks
FAQs
A simple, zero dependency tool for setting up git hooks for small projects
The npm package simple-git-hooks receives a total of 155,764 weekly downloads. As such, simple-git-hooks popularity was classified as popular.
We found that simple-git-hooks demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.