Skip to content

Commit

Permalink
feat(plugins): add getLastRelease hook
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ariporad authored and boennemann committed Aug 18, 2015
1 parent 77349fc commit 7ceac76
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 111 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -24,12 +24,12 @@
"@semantic-release/commit-analyzer": "^2.0.0",
"@semantic-release/condition-travis": "^4.0.0",
"@semantic-release/error": "^1.0.0",
"@semantic-release/last-release-npm": "^1.1.1",
"@semantic-release/release-notes-generator": "^2.0.0",
"git-head": "^1.2.1",
"github": "^0.2.4",
"lodash": "^3.9.3",
"nopt": "^3.0.3",
"npm-registry-client": "^6.4.0",
"npmconf": "^2.1.2",
"npmlog": "^1.2.1",
"parse-github-repo-url": "^1.0.0",
Expand Down
26 changes: 0 additions & 26 deletions src/lib/last-release.js

This file was deleted.

3 changes: 2 additions & 1 deletion src/lib/plugins.js
Expand Up @@ -5,7 +5,8 @@ let exports = module.exports = function (options) {
analyzeCommits: exports.normalize(options.analyzeCommits, '@semantic-release/commit-analyzer'),
generateNotes: exports.normalize(options.generateNotes, '@semantic-release/release-notes-generator'),
verifyConditions: exports.normalize(options.verifyConditions, '@semantic-release/condition-travis'),
verifyRelease: exports.normalize(options.verifyRelease, './plugin-noop')
verifyRelease: exports.normalize(options.verifyRelease, './plugin-noop'),
getLastRelease: exports.normalize(options.getLastRelease, '@semantic-release/last-release-npm')
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/pre.js
Expand Up @@ -2,14 +2,14 @@ const _ = require('lodash')
const auto = require('run-auto')
const semver = require('semver')

const getLastRelease = require('./lib/last-release')
const getCommits = require('./lib/commits')
const getType = require('./lib/type')

module.exports = function (config, cb) {
const {plugins} = config
const { plugins } = config

auto({
lastRelease: getLastRelease.bind(null, config),
lastRelease: plugins.getLastRelease.bind(null, config),
commits: ['lastRelease', (cb, results) => {
getCommits(_.assign({
lastRelease: results.lastRelease
Expand Down
79 changes: 0 additions & 79 deletions test/specs/last-release.js

This file was deleted.

9 changes: 8 additions & 1 deletion test/specs/pre.js
Expand Up @@ -6,9 +6,16 @@ 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')
analyzeCommits: (commits, cb) => cb(null, 'major'),
getLastRelease: ({ pkg }, cb) => {
cb(null, { version: versions[pkg.name] || null, gitHead: 'HEAD' })
}
}

const npm = {
Expand Down

0 comments on commit 7ceac76

Please sign in to comment.