This commit does a lot but it's all connected and tries to make everything more extensible and future proof. 1. CLI arguments and options from the "package.json" are no longer treated as two different things. You can now pass options either way. BREAKING CHANGE: cli arguments are now normalized to camelCase, so e.g. `options['github-url']` is now `options.githubUrl` 2. Plugins no longer receive config they need one by one, but in one huge object. This way it's easier to pass more info in the future w/o breaking existing plugins that rely on the position of the callback in the arguments array. BREAKING CHANGE: Plugins now need to read their passed options from one huge config object. Old: ```js module.exports = function (pluginConfig, foo, bar, cb) {…} ``` New: ```js // ES5 module.exports = function(pluginConfig, config, cb) { var foo = config.foo var bar = config.bar … } // ES6 module.exports = function (pluginConfig, {foo, bar}, cb) {…} ```
33 lines
880 B
JavaScript
33 lines
880 B
JavaScript
const test = require('tap').test
|
|
const proxyquire = require('proxyquire')
|
|
|
|
const commits = proxyquire('../../dist/lib/commits', {
|
|
'child_process': require('../mocks/child-process')
|
|
})
|
|
|
|
test('commits since last release', (t) => {
|
|
t.test('get all commits', (tt) => {
|
|
commits({lastRelease: {}}, (err, commits) => {
|
|
tt.error(err)
|
|
tt.is(commits.length, 2, 'all commits')
|
|
tt.is(commits[0].hash, 'hash-one', 'parsed hash')
|
|
tt.is(commits[1].message, 'commit-two', 'parsed message')
|
|
|
|
tt.end()
|
|
})
|
|
})
|
|
|
|
t.test('get commits since hash', (tt) => {
|
|
commits({lastRelease: {gitHead: 'hash'}}, (err, commits) => {
|
|
tt.error(err)
|
|
tt.is(commits.length, 1, 'specified commits')
|
|
tt.is(commits[0].hash, 'hash-one', 'parsed hash')
|
|
tt.is(commits[0].message, 'commit-one', 'parsed message')
|
|
|
|
tt.end()
|
|
})
|
|
})
|
|
|
|
t.end()
|
|
})
|