This repository has been archived by the owner on Dec 5, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add all intended functionality: [x] Fully compatable with semantic-release 4.0.0 plugin API [x] Gets last version from git tag [x] Calls callback with an error or a proper release object Fixes semantic-release/semantic-release#56
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { exec } = require('child_process') | ||
|
||
module.exports = function (pluginConfig, config, cb) { | ||
exec('git tag', (err, stdout, stderr) => { | ||
if (err) return cb(err) | ||
|
||
const versionRegex = /^v((?:[0-9]+\.){2}[0-9]+)$/ | ||
|
||
const tags = stdout | ||
.trim() | ||
.split('\n') | ||
.map(tag => tag.trim()) | ||
.filter(tag => versionRegex.test(tag)) | ||
|
||
if (tags.length < 1) return cb(null, {}) | ||
|
||
const tag = tags.pop() | ||
const version = tag.match(versionRegex)[1] | ||
|
||
cb(null, { | ||
version: version, | ||
gitHead: tag | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const { defaults } = require('lodash') | ||
const test = require('tap').test | ||
|
||
const lastRelease = require('../../dist') | ||
|
||
test('last release from git tags', (t) => { | ||
t.plan(1) | ||
|
||
t.test('TODO', (tt) => { | ||
lastRelease({}, { | ||
pkg: {name: 'available'} | ||
}, (err, release) => { | ||
tt.error(err) | ||
tt.is(release.version, '1.33.7', 'version') | ||
tt.is(release.gitHead, 'HEAD', 'gitHead') | ||
|
||
tt.end() | ||
}) | ||
}) | ||
}) |