Socket
Socket
Sign inDemoInstall

husky

Package Overview
Dependencies
4
Maintainers
1
Versions
207
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    husky

Prevents bad commit or push (git hooks, pre-commit/precommit, pre-push/prepush, post-merge/postmerge and all that stuff...)


Version published
Weekly downloads
11M
decreased by-1.89%
Maintainers
1
Install size
40.8 kB
Created
Weekly downloads
 

Package description

What is husky?

Husky is an npm package that allows you to manage Git hooks easily. It lets you run scripts at specific points in your Git workflow, such as before committing or pushing code. This helps in automating tasks like code linting, testing, and validation before these actions take place, ensuring code quality and consistency.

What are husky's main functionalities?

Pre-commit Hook

This feature allows you to run commands before a commit is made. In this example, `npm test` and `npm run lint` are executed before each commit, ensuring that tests pass and the code is linted.

"husky": {
  "hooks": {
    "pre-commit": "npm test && npm run lint"
  }
}

Pre-push Hook

This feature allows you to run commands before code is pushed to the repository. In this example, `npm run build` is executed before each push, ensuring that the build is updated.

"husky": {
  "hooks": {
    "pre-push": "npm run build"
  }
}

Commit-msg Hook

This feature allows you to run a script to validate the commit message. In this example, `validate-commit-msg.js` is a script that checks if the commit message follows a certain format.

"husky": {
  "hooks": {
    "commit-msg": "./validate-commit-msg.js"
  }
}

Other packages similar to husky

Readme

Source

husky npm version Build Status

Git hooks made easy

Husky can prevent bad commit, push and more :dog: woof!

Install

npm install husky --save-dev
// Edit package.json
{
  "scripts": {
    "precommit": "npm test",
    "prepush": "npm test",
    "...": "..."
  }
}
git commit -m "Keep calm and commit"

Existing hooks aren't replaced and you can use any Git hook.

Used by

Uninstall

npm uninstall husky --save-dev

Tricks

Debug hooks easily

If you need to debug hooks, simply use npm run <script-name>. For example:

npm run precommit

Git GUI clients support

If you've installed Node using the standard installer, nvm or homebrew, git hooks will be executed even in GUI applications.

In the case of nvm, husky will try to use the default installed version or use the project .nvmrc.

Accessing Git params

Git params can be found in GIT_PARAMS environment variable.

Git submodule support

Yes

Cygwin support

Yes

Yarn

For Yarn, you currently need to pass --force to be sure that hooks are going to be installed (yarn add husky --dev --force). You can also manually install hooks using node node_modules/husky/bin/install.

License

MIT - Typicode :cactus:

Keywords

FAQs

Last updated on 14 Dec 2016

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc