commit-message-validator
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -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" | ||
} | ||
} | ||
} | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6687
3
8
59
- Removedfs@^0.0.1-security
- Removedpath@^0.12.7
- Removedfs@0.0.1-security(transitive)
- Removedinherits@2.0.3(transitive)
- Removedpath@0.12.7(transitive)
- Removedprocess@0.11.10(transitive)
- Removedutil@0.10.4(transitive)