Skip to content

Commit

Permalink
fix: compatible with semantic-release@^12.4.1
Browse files Browse the repository at this point in the history
* chore(package): update semantic-release to version 12.4.1

Closes #8

* fix: compatible with semantic-release@^12.4.1

Fixes #9.

BREAKING CHANGE: This requires semantic release later than 12.4.1
and node 8.

* chore: add yarn.lock to npmignore

* chore: fix travis and SR
  • Loading branch information
elliotttf committed Jan 31, 2018
1 parent 169dc36 commit 04ace8b
Show file tree
Hide file tree
Showing 8 changed files with 3,467 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"parserOptions": {
"ecmaVersion": 6,
"ecmaVersion": 8,
"sourceType": "script"
},
"extends": "airbnb-base",
Expand Down
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
coverage
test
test/**/*.js
.coveralls.yml
.travis.yml
.eslintignore
.eslintrc.json
yarn.lock
13 changes: 5 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ cache:
notifications:
email: false
node_js:
- '7'
- '6'
before_script:
- npm prune
- '8'
script:
- npm run lint
- npm test
- yarn lint
- yarn test
after_success:
- npm run coveralls
- npm run semantic-release
- yarn coveralls
- yarn semantic-release
branches:
except:
- /^v\d+\.\d+\.\d+$/
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ To use this plugin, add the following to `package.json`:
## Configuration

By default, the behavior of this analyzer is very similar to the analyzer that
ships with semantic-release. In addition to `fix`, `feat` and `BREAKING CHANGE`
ships with semantic-release. In addition to `fix`, `feat` and `BREAKING CHANGE:`
support, the following messages create the corresponding releases:

* minor
Expand Down Expand Up @@ -60,4 +60,3 @@ The `mergePattern` and `mergeCorrespondence` allow you to detect a merge commit
and use the first line of the body as the header to determine the release type.

Note: configuring the type behavior will override the default type detection behavior.

17 changes: 14 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@

const parser = require('conventional-commits-parser').sync;

module.exports = (config, { commits }, cb) => {
/**
* Determine the type of release to create based on a list of commits.
*
* @param {Object} [config={}] semantic-release configuration
* @param {Object} options semantic-release options
* @param {Array} options.commits array of commits
*
* @return {Promise}
* The release type to use.
*/
async function conventionalCommitsAnalyzer(config, { commits }) {
let type = null;
const {
majorTypes = [],
Expand Down Expand Up @@ -40,6 +50,7 @@ module.exports = (config, { commits }, cb) => {
return true;
});

cb(null, type);
};
return type;
}

module.exports = conventionalCommitsAnalyzer;
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"precommit": "npm run lint",
"prepush": "npm test",
"commitmsg": "validate-commit-msg",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
"semantic-release": "semantic-release"
},
"keywords": [
"semantic-release",
Expand All @@ -25,18 +25,18 @@
"conventional-commits-parser": "^2.0.0"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"devDependencies": {
"coveralls": "^3.0.0",
"eslint": "^4.4.1",
"eslint-config-airbnb-base": "^11.1.0",
"eslint-plugin-import": "^2.2.0",
"husky": "^0.14.3",
"istanbul": "^0.4.5",
"istanbul": "^1.1.0-alpha.1",
"nodeunit": "^0.11.0",
"validate-commit-msg": "^2.11.1",
"semantic-release": "^7.0.1"
"semantic-release": "^12.4.1",
"validate-commit-msg": "^2.11.1"
},
"repository": {
"type": "git",
Expand Down
27 changes: 13 additions & 14 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ module.exports = {
hash: '',
message: 'feat(thing): Added the thing\nBREAKING CHANGE: api change',
}],
},
(err, type) => {
test.equal(type, 'major', 'Unexpected type.');
})
.then((type) => {
test.equal(type, 'major', 'Unexpected type for `BREAKING CHANGE:`.');
test.done();
});
},
minor(test) {
test.expect(1);
analyzer(
{},
{ commits: [{ hash: '', message: 'feat(thing): Added the thing' }] },
(err, type) => {
{ commits: [{ hash: '', message: 'feat(thing): Added the thing' }] })
.then((type) => {
test.equal(type, 'minor', 'Unexpected type.');
test.done();
});
Expand All @@ -33,8 +33,8 @@ module.exports = {
test.expect(1);
analyzer(
{},
{ commits: [{ hash: '', message: 'fix(thing): Added the thing' }] },
(err, type) => {
{ commits: [{ hash: '', message: 'fix(thing): Added the thing' }] })
.then((type) => {
test.equal(type, 'patch', 'Unexpected type.');
test.done();
});
Expand All @@ -44,8 +44,8 @@ module.exports = {
test.expect(1);
analyzer(
{ majorTypes: ['break'] },
{ commits: [{ hash: '', message: 'break(thing): Added the thing' }] },
(err, type) => {
{ commits: [{ hash: '', message: 'break(thing): Added the thing' }] })
.then((type) => {
test.equal(type, 'major', 'Unexpected type.');
test.done();
});
Expand All @@ -54,8 +54,8 @@ module.exports = {
test.expect(1);
analyzer(
{ minorTypes: ['minor'] },
{ commits: [{ hash: '', message: 'minor(thing): Added the thing' }] },
(err, type) => {
{ commits: [{ hash: '', message: 'minor(thing): Added the thing' }] })
.then((type) => {
test.equal(type, 'minor', 'Unexpected type.');
test.done();
});
Expand All @@ -64,11 +64,10 @@ module.exports = {
test.expect(1);
analyzer(
{ patchTypes: ['patch'] },
{ commits: [{ hash: '', message: 'patch(thing): Added the thing' }] },
(err, type) => {
{ commits: [{ hash: '', message: 'patch(thing): Added the thing' }] })
.then((type) => {
test.equal(type, 'patch', 'Unexpected type.');
test.done();
});
},
};

0 comments on commit 04ace8b

Please sign in to comment.