Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

commit-message-validator

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commit-message-validator - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.husky/commit-msg

4

lib/commit-message-validator.js

@@ -14,3 +14,3 @@ 'use strict'

try {
const root = findRoot(path.join(__dirname, '..', '..'))
const root = findRoot(process.cwd())
const packageJson = path.join(root, 'package.json')

@@ -39,3 +39,3 @@ const packageObj = JSON.parse(fs.readFileSync(packageJson, 'utf8'))

try {
const regex = new RegExp(pattern)
const regex = new RegExp(pattern, 'm')
if (regex.test(message)) {

@@ -42,0 +42,0 @@ process.exit(0)

{
"name": "commit-message-validator",
"version": "1.0.0",
"version": "1.0.1",
"description": "Git commit-msg hook validator",

@@ -10,3 +10,4 @@ "main": "index.js",

"precommit": "npm run lint",
"commitmsg": "node ./lib/cli.js"
"commitmsg": "node ./lib/cli.js",
"prepare": "husky install"
},

@@ -33,3 +34,3 @@ "repository": {

"eslint": "^5.16.0",
"husky": "^0.13.3"
"husky": "^7.0.2"
},

@@ -39,5 +40,3 @@ "dependencies": {

"find-git-root": "^1.0.0",
"find-root": "^1.0.0",
"fs": "^0.0.1-security",
"path": "^0.12.7"
"find-root": "^1.0.0"
},

@@ -44,0 +43,0 @@ "config": {

# commit-message-validator
Git commit-msg validator
This package provides you a binary that you can use as a git hook to validate the commit message.
This package provides you a binary that you can use as a git hook to validate the commit message, with your custom regex pattern.
This package can be used with githook packages such as [husky](https://www.npmjs.com/package/husky).
If you are using **husky**, add `"commitmsg": "commit-message-validator"` to your npm scripts in package.json.
If you are looking for a *standard* commit message validator which supports [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) out of sandbox, give [Commitlint](https://github.com/conventional-changelog/commitlint) a try.
# Installation
## Installation
This module is distributed via npm which is bundled with node and should be installed as one of your project's devDependencies:
npm install commit-message-validator
```bash
npm install -D commit-message-validator
```
# Usage
## Usage
1. Install this package as one of your project's devDependencies
2. Install githook [husky](https://www.npmjs.com/package/husky)
3. Config commit-msg hook to run commit-message-validator in package.json
3. Config commit-msg hook to run commit-message-validator.
{
"husky": {
"hooks": {
"commit-msg": "commit-message-validator"
}
}
**husky v7**
```bash
npm set-script prepare "husky install"
npx husky add .husky/commit-msg "npx commit-message-validator"
```
**husky v4**
setup husky in `package.json`.
```json
{
"husky": {
"hooks": {
"commit-msg": "commit-message-validator"
}
}
}
```
4. Custom commit-message regex pattern in package.json
{
"config": {
"commit-message-validator": {
"_comment": "pattern can be Regex string or array of Regex string",
"pattern": "your regex pattern here",
"errorMessage": "your error message"
}
}
```json
{
"config": {
"commit-message-validator": {
"_comment": "pattern can be Regex string or array of Regex string",
"pattern": "your regex pattern here",
"errorMessage": "your error message"
}
}
}
```
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc