commitplease
Advanced tools
Comparing version 1.9.0 to 1.10.0
var fs = require( "fs" ), | ||
path = require( "path" ), | ||
root = path.resolve( __dirname, "../.." ), | ||
chalk = require( "chalk" ), | ||
validate = require( "./lib/validate" ); | ||
validate = require( "./lib/validate" ), | ||
options = require( path.join( root, "package.json" ) ).commitplease || {}; | ||
module.exports = function( messageFile ) { | ||
var message = fs.readFileSync( messageFile ).toString(); | ||
var errors = validate( message ); | ||
var errors = validate( message, options ); | ||
if ( errors.length ) { | ||
@@ -8,0 +12,0 @@ console.error( "Invalid commit message, please fix the following issues:\n" ); |
@@ -35,2 +35,5 @@ var merge = require( "mout/object/merge" ), | ||
} | ||
if ( 0 === line.length ) { | ||
errors.push( "First line (subject) must not be empty" ); | ||
} | ||
if ( line.length > options.limits.subject ) { | ||
@@ -45,3 +48,3 @@ errors.push( "First line (subject) must be no longer than " + | ||
if ( line.substring( line.indexOf( ":" ) + 1 ).length < 1 ) { | ||
if ( options.component && line.substring( line.indexOf( ":" ) + 1 ).length < 1 ) { | ||
errors.push( "First line (subject) must have a message after the component" ); | ||
@@ -48,0 +51,0 @@ } |
{ | ||
"name": "commitplease", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "Validates strings as commit messages", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -21,3 +21,3 @@ # Commitplease | ||
*The API is a work-in-progress. Currently there's no way to customize options when using the bundled commit hook.* | ||
*The API is a work-in-progress* | ||
@@ -39,3 +39,2 @@ ```js | ||
Options and their defaults: | ||
@@ -51,2 +50,22 @@ | ||
### Customizing the bundled options | ||
The validation options can be overriden by configuring the `commitplease` property on your own project's `package.json`. This allows you to customize some of the validation rules available. | ||
Here's an example for disabling the `component` message validation: | ||
```json | ||
{ | ||
"name": "Example", | ||
"description": "An example project with custom commit hook options", | ||
"devDependencies": { | ||
"commitplease": "1.9.x" | ||
}, | ||
"commitplease": { | ||
"component": false | ||
} | ||
} | ||
``` | ||
## License | ||
@@ -53,0 +72,0 @@ Copyright 2014 Jörn Zaefferer. Released under the terms of the MIT license. |
11
test.js
@@ -83,2 +83,13 @@ var validate = require( "./lib/validate" ); | ||
{ | ||
msg: "", | ||
expected: [ "First line (subject) must not be empty" ], | ||
options: { | ||
component: false | ||
} | ||
}, | ||
{ | ||
msg: "", | ||
expected: [ "First line (subject) must not be empty", "First line (subject) must indicate the component", "First line (subject) must have a message after the component" ] | ||
}, | ||
{ | ||
msg: "Component: short message but actually a little bit over default character limit", | ||
@@ -85,0 +96,0 @@ expected: [ "First line (subject) must be no longer than 72 characters" ] |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
11805
303
73
3