commitplease
Advanced tools
Comparing version 2.5.0 to 2.6.0
#!/usr/bin/env node | ||
// `commitplease-original` | ||
// commitplease-original | ||
require('commitplease') |
@@ -21,4 +21,11 @@ var fs = require('fs') | ||
console.error(chalk.green(message)) | ||
if (options.style === undefined || options.style === 'jquery') { | ||
console.error('\nSee https://bit.ly/jquery-guidelines') | ||
} else if (options.style === 'angular') { | ||
console.error('\nSee https://bit.ly/angular-guidelines') | ||
} | ||
process.exit(1) | ||
} | ||
}()) |
@@ -0,6 +1,23 @@ | ||
var process = require('child_process') | ||
var command = 'git config --get core.commentchar' | ||
var comment = '#' | ||
try { | ||
comment = process.execSync(command).toString().trim() | ||
} catch (error) { | ||
// errors.status === 1 if the following: | ||
// a) 'core.commentchar' has not been set (git defaults it to #) | ||
// b) this is not a git repository | ||
// c) maybe something else? | ||
if (error.status !== 1) { | ||
throw error | ||
} | ||
} | ||
var scissor = /# ------------------------ >8 ------------------------[\s\S]+/ | ||
module.exports = function (value) { | ||
var isComment = new RegExp('^' + comment) | ||
return value.replace(scissor, '').split(/\n/).filter(function (line) { | ||
return !/^#/.test(line) | ||
return !isComment.test(line) | ||
}).join('\n').trim() | ||
} |
@@ -20,3 +20,3 @@ module.exports = function (lines, options, errors) { | ||
if (line.indexOf('(') === -1) { | ||
errors.push(prefix + 'Missing opening parethesis "("') | ||
errors.push(prefix + 'Need an opening parethesis "("') | ||
@@ -47,5 +47,3 @@ return | ||
if (line.indexOf(')') === -1) { | ||
errors.push( | ||
prefix + 'Need a closing parenthesis ")" after <scope>' | ||
) | ||
errors.push(prefix + 'Need a closing parenthesis ")" after <scope>') | ||
@@ -66,5 +64,3 @@ return | ||
if (line.indexOf(type + '(' + scope + '):') === -1) { | ||
errors.push( | ||
prefix + 'Need a colon ":" after the closing parenthesis ")"' | ||
) | ||
errors.push(prefix + 'Need a colon ":" after the closing parenthesis ")"') | ||
@@ -77,3 +73,3 @@ return | ||
if (!subject.startsWith(' ')) { | ||
errors.push(prefix + 'There must be a space " " after colon ":"') | ||
errors.push(prefix + 'Need a space " " after colon ":"') | ||
@@ -80,0 +76,0 @@ return |
@@ -36,5 +36,3 @@ module.exports = function (lines, options, errors) { | ||
if (line.substring(line.indexOf(':') + 1).length < 1) { | ||
errors.push( | ||
prefix + '<subject> was empty' | ||
) | ||
errors.push(prefix + '<subject> was empty') | ||
@@ -41,0 +39,0 @@ return |
{ | ||
"name": "commitplease", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "Validates strings as commit messages", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Commitplease | ||
[![Build Status](https://secure.travis-ci.org/jzaefferer/commitplease.png)](http://travis-ci.org/jzaefferer/commitplease) | ||
[![Travis](https://img.shields.io/travis/jzaefferer/commitplease.svg?maxAge=2592000)](http://travis-ci.org/jzaefferer/commitplease) | ||
[![npm](https://img.shields.io/npm/dm/commitplease.svg?maxAge=2592000)](https://www.npmjs.com/package/commitplease) | ||
[![npm](https://img.shields.io/npm/v/commitplease.svg?maxAge=2592000)](https://www.npmjs.com/package/commitplease) | ||
[![npm](https://img.shields.io/npm/l/commitplease.svg?maxAge=2592000)](https://www.npmjs.com/package/commitplease) | ||
@@ -30,2 +33,4 @@ This [node.js](http://nodejs.org/) module makes sure your git commit messages consistently follow one of these style guides: | ||
Another special scenario is to do `git commit --no-verify` which will skip the commit-msg hook and bypass commitplease. | ||
Common commit messages follow one of the style guides ([jQuery Commit Guidelines][1] by default) | ||
@@ -169,2 +174,22 @@ | ||
## Uninstall | ||
Remove your configurations of commitplease from your package.json, if any. | ||
If you are running `npm 2.x`, then: | ||
``` | ||
npm uninstall commitplease --save-dev | ||
``` | ||
If you are running `npm 3.x`, you will have to remove the hook manually: | ||
``` | ||
rm .git/hooks/commit-msg | ||
npm uninstall commitplease --save-dev | ||
``` | ||
There is [an open issue](https://github.com/npm/npm/issues/13381) to npm about this. | ||
## License | ||
@@ -171,0 +196,0 @@ Copyright Jörn Zaefferer |
@@ -57,3 +57,3 @@ ;(function avoidSelfInstall () { | ||
var content = fs.readFileSync(hook, 'utf-8') | ||
if (content && content.split('\n')[ 1 ] === '// commitplease-original') { | ||
if (content && content.split('\n')[ 2 ] === '// commitplease-original') { | ||
context.selfmadeHook = true | ||
@@ -60,0 +60,0 @@ } |
220
test.js
@@ -6,2 +6,28 @@ var merge = require('mout/object/merge') | ||
var jqueryColon = | ||
'First line must be <Component>": "<subject>\n' + | ||
'Missing colon ":"' | ||
var jqueryComponent = | ||
'First line must be <Component>": "<subject>\n' + | ||
'<Component> invalid, was "Component", must be one of these:\n' + | ||
'Build, Legacy' | ||
var jqueryEmptyComponent = | ||
'First line must be <Component>": "<subject>\n' + | ||
'<Component> was empty, must be one of these:\n' | ||
var jqueryTestComponent = | ||
'First line must be <Component>": "<subject>\n' + | ||
'<Component> invalid, was "Test", must be one of these:\n' + | ||
'Build, Legacy' | ||
var jqueryFixComponent = | ||
'First line must be <Component>": "<subject>\n' + | ||
'<Component> invalid, was "[fix]", must be one of these:\n' + | ||
'Build, Legacy' | ||
var jqueryTmpComponent = | ||
'First line must be <Component>": "<subject>\n' + | ||
'<Component> invalid, was "[Tmp]", must be one of these:\n' + | ||
'Build, Legacy' | ||
var jqueryEmptySubject = | ||
'First line must be <Component>": "<subject>\n' + | ||
'<subject> was empty' | ||
var jquery0 = defaults.jquery | ||
@@ -68,11 +94,14 @@ | ||
reasons: new Map([ | ||
[jquery0, | ||
['First line must be <Component>": "<subject>\nMissing colon ":"'] | ||
], | ||
[jquery3, | ||
['First line must be <Component>": "<subject>\nMissing colon ":"'] | ||
] | ||
[jquery0, [jqueryColon]], | ||
[jquery3, [jqueryColon]] | ||
]) | ||
}, | ||
{ | ||
msg: ':No component here, short message', | ||
reasons: new Map([ | ||
[jquery0, [jqueryEmptyComponent]], | ||
[jquery3, [jqueryEmptyComponent]] | ||
]) | ||
}, | ||
{ | ||
msg: '# comment\n' + | ||
@@ -82,8 +111,4 @@ 'No component here, short message', | ||
reasons: new Map([ | ||
[jquery0, | ||
['First line must be <Component>": "<subject>\nMissing colon ":"'] | ||
], | ||
[jquery3, | ||
['First line must be <Component>": "<subject>\nMissing colon ":"'] | ||
] | ||
[jquery0, [jqueryColon]], | ||
[jquery3, [jqueryColon]] | ||
]) | ||
@@ -97,8 +122,3 @@ }, | ||
msg: 'Test: short message', | ||
reasons: new Map([ | ||
[jquery2, | ||
['First line must be <Component>": "<subject>\n' + | ||
'<Component> invalid, was "Test", must be one of these:\nBuild, Legacy'] | ||
] | ||
]) | ||
reasons: new Map([[jquery2, [jqueryTestComponent]]]) | ||
}, | ||
@@ -123,4 +143,3 @@ { | ||
['First line of commit message must be no longer than 72 characters', | ||
'First line must be <Component>": "<subject>\n' + | ||
'<Component> invalid, was "Component", must be one of these:\nBuild, Legacy'] | ||
jqueryComponent] | ||
], | ||
@@ -155,11 +174,5 @@ [jquery3, | ||
reasons: new Map([ | ||
[jquery0, | ||
['First line must be <Component>": "<subject>\n<subject> was empty'] | ||
], | ||
[jquery2, | ||
['First line must be <Component>": "<subject>\n<subject> was empty'] | ||
], | ||
[jquery3, | ||
['First line must be <Component>": "<subject>\n<subject> was empty'] | ||
] | ||
[jquery0, [jqueryEmptySubject]], | ||
[jquery2, [jqueryEmptySubject]], | ||
[jquery3, [jqueryEmptySubject]] | ||
]) | ||
@@ -506,2 +519,32 @@ }, | ||
var angularOpening = | ||
'First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Need an opening parethesis "("' | ||
var angularOpeningRevert = | ||
'First line must be "revert: "<type>"("<scope>"): "<subject>\n' + | ||
'Need an opening parethesis "("' | ||
var angularClosing = | ||
'First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Need a closing parenthesis ")" after <scope>' | ||
var angularSpace = | ||
'First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Need a space " " after colon ":"' | ||
var angularScope = | ||
'First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Scope does not match \\S+.*' | ||
var angularColon = | ||
'First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Need a colon ":" after the closing parenthesis ")"' | ||
var angularLowercase = | ||
'<subject> must start with a lowercase letter' | ||
var angularDot = | ||
'<subject> must not end with a dot "."' | ||
var angularIfRevert = | ||
'If this is a revert of a previous commit, please write:\n' + | ||
'"revert: "<type>"("<scope>"): "<subject>"' | ||
var angularEmptyTypeRevert = | ||
'First line must be "revert: "<type>"("<scope>"): "<subject>\n' + | ||
'<type> was empty, must be one of these:\n' + | ||
'feat, fix, docs, style, refactor, perf, test, chore' | ||
var angular0 = defaults.angular | ||
@@ -558,142 +601,63 @@ | ||
msg: 'feat', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Missing opening parethesis "("'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularOpening]]]) | ||
}, | ||
{ | ||
msg: 'feat subject', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Missing opening parethesis "("'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularOpening]]]) | ||
}, | ||
{ | ||
msg: 'feat: subject', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Missing opening parethesis "("'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularOpening]]]) | ||
}, | ||
{ | ||
msg: 'feat(', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Need a closing parenthesis ")" after <scope>'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularClosing]]]) | ||
}, | ||
{ | ||
msg: 'feat()', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Scope does not match \\S+.*'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularScope]]]) | ||
}, | ||
{ | ||
msg: 'feat(scope)', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be <type>"("<scope>"): "<subject>\n' + | ||
'Need a colon ":" after the closing parenthesis ")"'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularColon]]]) | ||
}, | ||
{ | ||
msg: 'feat(scope):', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be <type>"("<scope>"): "<subject>\n' + | ||
'There must be a space " " after colon ":"' ] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularSpace]]]) | ||
}, | ||
{ | ||
msg: 'feat(scope):subject', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be <type>"("<scope>"): "<subject>\n' + | ||
'There must be a space " " after colon ":"'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularSpace]]]) | ||
}, | ||
{ | ||
msg: 'feat(scope): Subject', | ||
reasons: new Map([ | ||
[angular0, | ||
['<subject> must start with a lowercase letter'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularLowercase]]]) | ||
}, | ||
{ | ||
msg: 'feat(scope): subject.', | ||
reasons: new Map([ | ||
[angular0, | ||
['<subject> must not end with a dot "."'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularDot]]]) | ||
}, | ||
{ | ||
msg: 'revert this commit', | ||
reasons: new Map([ | ||
[angular0, | ||
['If this is a revert of a previous commit, please write:\n' + | ||
'"revert: "<type>"("<scope>"): "<subject>"'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularIfRevert]]]) | ||
}, | ||
{ | ||
msg: 'revert(scope): subject', | ||
reasons: new Map([ | ||
[angular0, | ||
['If this is a revert of a previous commit, please write:\n' + | ||
'"revert: "<type>"("<scope>"): "<subject>"'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularIfRevert]]]) | ||
}, | ||
{ | ||
msg: 'revert: (scope): subject', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be "revert: "<type>"("<scope>"): "<subject>\n' + | ||
'<type> was empty, must be one of these:\n' + | ||
'feat, fix, docs, style, refactor, perf, test, chore'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularEmptyTypeRevert]]]) | ||
}, | ||
{ | ||
msg: 'revert: feat: subject', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be "revert: "<type>"("<scope>"): "<subject>\n' + | ||
'Missing opening parethesis "("'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularOpeningRevert]]]) | ||
}, | ||
{ | ||
msg: 'revert: subject', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be "revert: "<type>"("<scope>"): "<subject>\n' + | ||
'Missing opening parethesis "("'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularOpeningRevert]]]) | ||
}, | ||
{ | ||
msg: 'feat(scope1):docs(scope2): subject', | ||
reasons: new Map([ | ||
[angular0, | ||
['First line must be <type>"("<scope>"): "<subject>\n' + | ||
'There must be a space " " after colon ":"'] | ||
] | ||
]) | ||
reasons: new Map([[angular0, [angularSpace]]]) | ||
} | ||
@@ -737,4 +701,4 @@ ] | ||
reasons: new Map([ | ||
[jquery2, ['First line must be <Component>": "<subject>\n<Component> invalid, was "[fix]", must be one of these:\nBuild, Legacy']], | ||
[angular0, ['First line must be <type>"("<scope>"): "<subject>\nMissing opening parethesis "("']] | ||
[jquery2, [jqueryFixComponent]], | ||
[angular0, [angularOpening]] | ||
]) | ||
@@ -745,4 +709,4 @@ }, | ||
reasons: new Map([ | ||
[jquery2, ['First line must be <Component>": "<subject>\n<Component> invalid, was "[Tmp]", must be one of these:\nBuild, Legacy']], | ||
[angular0, ['First line must be <type>"("<scope>"): "<subject>\nMissing opening parethesis "("']] | ||
[jquery2, [jqueryTmpComponent]], | ||
[angular0, [angularOpening]] | ||
]) | ||
@@ -749,0 +713,0 @@ }, |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
40790
203
1122
1