Merge pull request #6 from boennemann/fix-git-node
refactor(post): use git-head instead of exec
This commit is contained in:
commit
6f891ed781
@ -11,6 +11,7 @@
|
|||||||
"abbrev": "^1.0.5",
|
"abbrev": "^1.0.5",
|
||||||
"conventional-changelog": "0.0.11",
|
"conventional-changelog": "0.0.11",
|
||||||
"error-first-handler": "^1.0.1",
|
"error-first-handler": "^1.0.1",
|
||||||
|
"git-head": "^1.0.0",
|
||||||
"github": "^0.2.3",
|
"github": "^0.2.3",
|
||||||
"github-url-from-git": "^1.4.0",
|
"github-url-from-git": "^1.4.0",
|
||||||
"ini": "^1.3.2",
|
"ini": "^1.3.2",
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
var exec = require('child_process').exec
|
|
||||||
var readFile = require('fs').readFileSync
|
var readFile = require('fs').readFileSync
|
||||||
var url = require('url')
|
var url = require('url')
|
||||||
|
|
||||||
var changelog = require('conventional-changelog')
|
var changelog = require('conventional-changelog')
|
||||||
|
var gitHead = require('git-head')
|
||||||
var GitHubApi = require('github')
|
var GitHubApi = require('github')
|
||||||
var parseSlug = require('parse-github-repo-url')
|
var parseSlug = require('parse-github-repo-url')
|
||||||
var parseUrl = require('github-url-from-git')
|
var parseUrl = require('github-url-from-git')
|
||||||
@ -31,7 +31,7 @@ module.exports = function (options, cb) {
|
|||||||
repository: parseUrl(repository),
|
repository: parseUrl(repository),
|
||||||
file: false
|
file: false
|
||||||
}, efh(cb)(function (log) {
|
}, efh(cb)(function (log) {
|
||||||
exec('git rev-parse HEAD', efh(cb)(function (hash) {
|
gitHead(efh(cb)(function (hash) {
|
||||||
var ghRepo = parseSlug(repository)
|
var ghRepo = parseSlug(repository)
|
||||||
var release = {
|
var release = {
|
||||||
owner: ghRepo[0],
|
owner: ghRepo[0],
|
||||||
|
@ -25,18 +25,31 @@ module.exports = function (test, createModule) {
|
|||||||
}
|
}
|
||||||
}, efh()(function (name, cwd) {
|
}, efh()(function (name, cwd) {
|
||||||
test('postpublish', function (t) {
|
test('postpublish', function (t) {
|
||||||
t.test('publish new version to github releases', function (t) {
|
var base = nixt()
|
||||||
t.plan(1)
|
|
||||||
|
|
||||||
nixt()
|
|
||||||
.cwd(cwd)
|
.cwd(cwd)
|
||||||
.env('CI', true)
|
.env('CI', true)
|
||||||
.env('GH_URL', 'http://127.0.0.1:4343/')
|
.env('GH_URL', 'http://127.0.0.1:4343/')
|
||||||
.env('GH_TOKEN', '***')
|
.env('GH_TOKEN', '***')
|
||||||
.exec('git commit --allow-empty -m "feat(cool): the next big thing"')
|
.exec('git commit --allow-empty -m "feat(cool): the next big thing"')
|
||||||
.run('npm run postpublish')
|
|
||||||
.code(0)
|
.code(0)
|
||||||
.stdout(/> semantic-release post\n\nGenerating changelog from.*\nParsed/m)
|
.stdout(/> semantic-release post\n\nGenerating changelog from.*\nParsed/m)
|
||||||
|
|
||||||
|
t.test('publish new version to github releases', function (t) {
|
||||||
|
t.plan(1)
|
||||||
|
|
||||||
|
base.clone()
|
||||||
|
.run('npm run postpublish')
|
||||||
|
.end(function(err) {
|
||||||
|
t.error(err, 'nixt')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
t.test('publish new version (with detached HEAD) to github releases', function (t) {
|
||||||
|
t.plan(1)
|
||||||
|
|
||||||
|
base.clone()
|
||||||
|
.exec('git checkout `git rev-parse HEAD`')
|
||||||
|
.run('npm run postpublish')
|
||||||
.end(function(err) {
|
.end(function(err) {
|
||||||
t.error(err, 'nixt')
|
t.error(err, 'nixt')
|
||||||
})
|
})
|
||||||
@ -49,7 +62,7 @@ module.exports = function (test, createModule) {
|
|||||||
t.error(err, 'github')
|
t.error(err, 'github')
|
||||||
t.is(res.tag_name, 'v2.0.0', 'version')
|
t.is(res.tag_name, 'v2.0.0', 'version')
|
||||||
t.is(res.author.login, 'user', 'user')
|
t.is(res.author.login, 'user', 'user')
|
||||||
t.ok(/\n\n\n#### Features\n\n\* \*\*cool:\*\* the next big thing/.test(res.body), 'body')
|
t.ok(/\n\n\n#### Features\n\n\* \*\*cool:\*\*\n.*the next big thing/.test(res.body), 'body')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user