The code to determine the last-release is now in its own repository: https://github.com/semantic-release/last-release-npm One can overwrite that behavior by defining a "getLastRelease" plugin. This way one can decouple semantic-release from npm, e.g. by implementing a git-tag based version. This is already worked on: https://github.com/semantic-release/last-release-git-tag Closes #56
58 lines
1.1 KiB
JavaScript
58 lines
1.1 KiB
JavaScript
const test = require('tap').test
|
|
const proxyquire = require('proxyquire')
|
|
|
|
require('../mocks/registry')
|
|
const pre = proxyquire('../../dist/pre', {
|
|
'child_process': require('../mocks/child-process')
|
|
})
|
|
|
|
const versions = {
|
|
available: '1.0.0'
|
|
}
|
|
|
|
const plugins = {
|
|
verifyRelease: (release, cb) => cb(null, release),
|
|
analyzeCommits: (commits, cb) => cb(null, 'major'),
|
|
getLastRelease: ({ pkg }, cb) => {
|
|
cb(null, { version: versions[pkg.name] || null, gitHead: 'HEAD' })
|
|
}
|
|
}
|
|
|
|
const npm = {
|
|
registry: 'http://registry.npmjs.org/',
|
|
tag: 'latest'
|
|
|
|
}
|
|
|
|
test('full pre run', (t) => {
|
|
t.test('increase version', (tt) => {
|
|
tt.plan(3)
|
|
|
|
pre({
|
|
npm,
|
|
pkg: {name: 'available'},
|
|
plugins
|
|
}, (err, release) => {
|
|
tt.error(err)
|
|
tt.is(release.type, 'major')
|
|
tt.is(release.version, '2.0.0')
|
|
})
|
|
})
|
|
|
|
t.test('increase version', (tt) => {
|
|
tt.plan(3)
|
|
|
|
pre({
|
|
npm,
|
|
pkg: {name: 'unavailable'},
|
|
plugins
|
|
}, (err, release) => {
|
|
tt.error(err)
|
|
tt.is(release.type, 'initial')
|
|
tt.is(release.version, '1.0.0')
|
|
})
|
|
})
|
|
|
|
t.end()
|
|
})
|