feat(plugins): normalize plugins and have unified function signature
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
let exports = module.exports = function (source) {
|
||||
return {
|
||||
analyze: exports.normalize(source.analyze, '@semantic-release/commit-analyzer'),
|
||||
generateNotes: exports.normalize(source.analyze, '@semantic-release/release-notes-generator'),
|
||||
verify: exports.normalize(source.verify, './plugin-noop')
|
||||
}
|
||||
}
|
||||
|
||||
exports.normalize = function (plugin, fallback) {
|
||||
if (typeof plugin === 'string') return require(plugin).bind(null, {})
|
||||
|
||||
if (plugin && (typeof plugin.path === 'string')) {
|
||||
return require(plugin.path).bind(null, plugin)
|
||||
}
|
||||
|
||||
return require(fallback).bind(null, plugin)
|
||||
}
|
||||
Reference in New Issue
Block a user