Socket
Socket
Sign inDemoInstall

conventional-commits-parser

Package Overview
Dependencies
66
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.7 to 0.0.8

3

cli.js

@@ -80,5 +80,3 @@ #!/usr/bin/env node

var commit = '';
var stream = through();
var rl = readline.createInterface({

@@ -89,2 +87,3 @@ input: process.stdin,

});
cli.flags.warn = console.log.bind(console);

@@ -91,0 +90,0 @@ stream.pipe(conventionalCommitsParser(cli.flags))

@@ -6,3 +6,11 @@ 'use strict';

function parser(raw, options) {
var warn;
if (!_.isEmpty(options)) {
warn = options.warn || function() {};
} else {
return null;
}
if (!raw || !raw.trim()) {
warn('Cannot parse raw commit');
return null;

@@ -31,2 +39,3 @@ }

if (!msg.header) {
warn('Cannot parse commit header');
return null;

@@ -36,4 +45,8 @@ }

match = msg.header.match(options.headerPattern);
if (!match || !match[1] || !match[3]) {
if (!match || !match[1]) {
warn('Cannot parse commit type');
return null;
} else if (!match[3]) {
warn('Cannot parse commit subject');
return null;
}

@@ -40,0 +53,0 @@

{
"name": "conventional-commits-parser",
"version": "0.0.7",
"version": "0.0.8",
"description": "Parse raw conventional commits",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/stevemao/conventional-commits-parser",

@@ -146,3 +146,9 @@ # [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverall-image]][coverall-url]

##### warn
Type: `function`
What warn function to use. For example, `console.warn.bind(console)` or `grunt.log.writeln`. By default, it's a noop.
## CLI

@@ -149,0 +155,0 @@

@@ -6,36 +6,42 @@ 'use strict';

describe('parseRawCommit', function() {
var options = {
maxSubjectLength: 80,
headerPattern: /^(\w*)(?:\(([\w\$\.\-\* ]*)\))?\: (.*)$/,
closeKeywords: [
'kill',
'kills',
'killed',
'handle',
'handles',
'handled'
],
breakKeywords: [
'BREAKING AMEND'
]
};
var options;
var msg;
var simpleMsg;
var msg = parser(
'9b1aff905b638aa274a5fc8f88662df446d374bd\n' +
'feat(scope): broadcast $destroy event on scope destruction\n' +
'perf testing shows that in chrome this change adds 5-15% overhead\n' +
'when destroying 10k nested scopes where each scope has a $destroy listener\n' +
'BREAKING AMEND: some breaking change\n' +
'Kills #1, #123\n' +
'killed #25\n' +
'handle #33, Closes #100, Handled #3',
options
);
beforeEach(function() {
options = {
maxSubjectLength: 80,
headerPattern: /^(\w*)(?:\(([\w\$\.\-\* ]*)\))?\: (.*)$/,
closeKeywords: [
'kill',
'kills',
'killed',
'handle',
'handles',
'handled'
],
breakKeywords: [
'BREAKING AMEND'
]
};
var simpleMsg = parser(
'chore: some chore\n',
options
);
msg = parser(
'9b1aff905b638aa274a5fc8f88662df446d374bd\n' +
'feat(scope): broadcast $destroy event on scope destruction\n' +
'perf testing shows that in chrome this change adds 5-15% overhead\n' +
'when destroying 10k nested scopes where each scope has a $destroy listener\n' +
'BREAKING AMEND: some breaking change\n' +
'Kills #1, #123\n' +
'killed #25\n' +
'handle #33, Closes #100, Handled #3',
options
);
it('should returns null if nothing to parse', function() {
simpleMsg = parser(
'chore: some chore\n',
options
);
});
it('should return null if nothing to parse', function() {
expect(parser()).to.equal(null);

@@ -46,2 +52,20 @@ expect(parser('\n')).to.equal(null);

it('should warn if nothing to parse', function() {
parser('', {
warn: function(warning) {
expect(warning).to.equal('Cannot parse raw commit');
}
});
parser('\n', {
warn: function(warning) {
expect(warning).to.equal('Cannot parse raw commit');
}
});
parser(' ', {
warn: function(warning) {
expect(warning).to.equal('Cannot parse raw commit');
}
});
});
it('should parse hash', function() {

@@ -52,10 +76,32 @@ expect(msg.hash).to.equal('9b1aff905b638aa274a5fc8f88662df446d374bd');

describe('header', function() {
it('should returns null if header cannot be parsed', function() {
it('should return null if header cannot be parsed', function() {
expect(parser('bla bla', options)).to.equal(null);
});
it('should returns null if there is no header', function() {
it('should warn if type cannot be parsed', function() {
parser('bla bla', {
warn: function(warning) {
expect(warning).to.equal('Cannot parse commit type');
}
});
});
it('should warn if subject cannot be parsed', function() {
options.warn = function(warning) {
expect(warning).to.equal('Cannot parse commit subject');
};
parser('fix: ', options);
});
it('should return null if there is no header', function() {
expect(parser('056f5827de86cace1f282c8e3f1cccc952fcad2e', options)).to.equal(null);
});
it('should warn if header cannot be parsed', function() {
options.warn = function(warning) {
expect(warning).to.equal('Cannot parse commit header');
};
parser('056f5827de86cace1f282c8e3f1cccc952fcad2e', options);
});
it('should parse header', function() {

@@ -62,0 +108,0 @@ expect(msg.header).to.equal('feat(scope): broadcast $destroy event on scope destruction');

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