diff --git a/src/lib/commits.js b/src/lib/commits.js index e844545e..b2a0a1ab 100644 --- a/src/lib/commits.js +++ b/src/lib/commits.js @@ -1,7 +1,7 @@ const { exec } = require('child_process') -module.exports = function (results, cb) { - const from = results.lastRelease.gitHead +module.exports = function (lastRelease, cb) { + const from = lastRelease.gitHead const range = (from ? from + '..' : '') + 'HEAD' exec( diff --git a/src/lib/type.js b/src/lib/type.js index 81640dde..d46c7fff 100644 --- a/src/lib/type.js +++ b/src/lib/type.js @@ -1,9 +1,6 @@ const SemanticReleaseError = require('./error') -module.exports = function (plugins, results, cb) { - const commits = results.commits - const lastRelease = results.lastRelease - +module.exports = function (plugins, commits, lastRelease, cb) { const type = plugins.analyze(commits) if (!type) { diff --git a/test/specs/commits.js b/test/specs/commits.js index 6a04fa33..82e2b1bd 100644 --- a/test/specs/commits.js +++ b/test/specs/commits.js @@ -7,7 +7,7 @@ const commits = proxyquire('../../dist/lib/commits', { test('commits since last release', (t) => { t.test('get all commits', (t) => { - commits({lastRelease: {}}, (err, commits) => { + commits({}, (err, commits) => { t.error(err) t.is(commits.length, 2, 'all commits') t.is(commits[0].hash, 'hash-one', 'parsed hash') @@ -16,7 +16,7 @@ test('commits since last release', (t) => { }) t.test('get commits since hash', (t) => { - commits({lastRelease: {gitHead: 'hash'}}, (err, commits) => { + commits({gitHead: 'hash'}, (err, commits) => { t.error(err) t.is(commits.length, 1, 'specified commits') t.is(commits[0].hash, 'hash-one', 'parsed hash') diff --git a/test/specs/type.js b/test/specs/type.js index c32d8251..5fb92499 100644 --- a/test/specs/type.js +++ b/test/specs/type.js @@ -6,14 +6,11 @@ test('get type from commits', (t) => { t.test('get type from plugin', (t) => { type({ analyze: () => 'major' - }, { - commits: [{ - hash: '0', - message: 'a' - }], - lastRelease: { - version: '1.0.0' - } + }, [{ + hash: '0', + message: 'a' + }], { + version: '1.0.0' }, (err, type) => { t.error(err) t.is(type, 'major') @@ -23,20 +20,17 @@ test('get type from commits', (t) => { t.test('error when no changes', (t) => { type({ analyze: () => null - }, { - commits: [], - lastRelease: {} - }, (err) => { + }, [], {}, + (err) => { t.is(err.code, 'ENOCHANGE') }) }) t.test('initial version', (t) => { - type({}, { - lastRelease: { - version: null - } - }, (err, type) => { + type({ + analyze: () => 'major' + }, [], {}, + (err, type) => { t.error(err) t.is(type, 'initial') })