Skip to content

Commit

Permalink
chore: ignore exit code instead of catching errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tsvetomir committed Aug 21, 2017
1 parent 0a733b8 commit c3be373
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
12 changes: 3 additions & 9 deletions analyzeCommits.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const analyzeCommits = require('@semantic-release/commit-analyzer')
const SemanticReleaseError = require('@semantic-release/error')
const execSync = require('child_process').execSync;
const lastTag = require('./lastTag');

const until = f => array => {
const first = array[0];
Expand All @@ -13,15 +14,8 @@ const until = f => array => {
};

const lastTaggedRelease = () => {
let sha;

try {
sha = execSync('git rev-list -1 `git describe --tags --abbrev=0 --match "v[0-9]*"`', {
encoding: 'utf8'
}).trim();
} catch(e) {}

return sha;
const tag = lastTag({ branch: '', dev: false });
execSync(`git rev-list -1 ${tag}`, { encoding: 'utf8' }).trim();
};

module.exports = function (pluginConfig, config, cb) {
Expand Down
18 changes: 6 additions & 12 deletions lastTag.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
const execSync = require('child_process').execSync;

const lastTag = () => {
let sha;

try {
sha = execSync(
'git describe --tags --match "v[0-9]*" --exclude="*dev*" --abbrev=0 origin/master',
{ encoding: 'utf8' }
).trim();
} catch(e) {}

return sha;
}
const lastTag = ({ branch = 'origin/master', dev = true } = {}) => {
const exclude = dev ? ' --exclude="*dev*"' : '';
return execSync(`git describe --tags --match "v[0-9]*" ${exclude} --abbrev=0 ${branch} || true`,
{ encoding: 'utf8' }
).trim();
};

module.exports = lastTag;

0 comments on commit c3be373

Please sign in to comment.