feat(plugins): run verifications in series
With this new feature you can pass an array of plugin locations/names to both "verifyConditions" and "verifyRelease" in your `package.json`'s "release" field. This will run multiple verification plugins in series.
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
module.exports = function (config, options, cb) {
|
||||
cb(new Error('a'))
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (config, options, cb) {
|
||||
cb(new Error('b'))
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (config, options, cb) {
|
||||
cb(null, 'a')
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (config, options, cb) {
|
||||
cb(null, 'b')
|
||||
}
|
||||
+54
-1
@@ -3,7 +3,7 @@ const test = require('tap').test
|
||||
const plugins = require('../../dist/lib/plugins')
|
||||
|
||||
test('export plugins', (t) => {
|
||||
t.plan(4)
|
||||
t.plan(5)
|
||||
|
||||
const defaultPlugins = plugins({})
|
||||
|
||||
@@ -11,6 +11,59 @@ test('export plugins', (t) => {
|
||||
t.is(typeof defaultPlugins.generateNotes, 'function')
|
||||
t.is(typeof defaultPlugins.verifyConditions, 'function')
|
||||
t.is(typeof defaultPlugins.verifyRelease, 'function')
|
||||
t.is(typeof defaultPlugins.getLastRelease, 'function')
|
||||
})
|
||||
|
||||
test('plugin pipelines', (t) => {
|
||||
t.plan(3)
|
||||
|
||||
t.test('get all results', (tt) => {
|
||||
const pipelinePlugins = plugins({
|
||||
verifyRelease: [
|
||||
'./dist/lib/plugin-noop',
|
||||
'./.test/mocks/plugin-result-a',
|
||||
'./.test/mocks/plugin-result-b'
|
||||
]
|
||||
})
|
||||
|
||||
pipelinePlugins.verifyRelease({}, (err, results) => {
|
||||
tt.error(err)
|
||||
tt.same(results, [undefined, 'a', 'b'])
|
||||
tt.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('get first error', (tt) => {
|
||||
const pipelinePlugins = plugins({
|
||||
verifyConditions: [
|
||||
'./dist/lib/plugin-noop',
|
||||
'./.test/mocks/plugin-error-a',
|
||||
'./.test/mocks/plugin-error-b'
|
||||
]
|
||||
})
|
||||
|
||||
pipelinePlugins.verifyConditions({}, (err) => {
|
||||
tt.is(err.message, 'a')
|
||||
tt.end()
|
||||
})
|
||||
})
|
||||
|
||||
t.test('get error and only results before', (tt) => {
|
||||
const pipelinePlugins = plugins({
|
||||
verifyRelease: [
|
||||
'./dist/lib/plugin-noop',
|
||||
'./.test/mocks/plugin-result-a',
|
||||
'./.test/mocks/plugin-error-b',
|
||||
'./.test/mocks/plugin-result-b'
|
||||
]
|
||||
})
|
||||
|
||||
pipelinePlugins.verifyRelease({}, (err, results) => {
|
||||
tt.is(err.message, 'b')
|
||||
tt.same(results, [undefined, 'a', undefined])
|
||||
tt.end()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('normalize and load plugin', (t) => {
|
||||
|
||||
Reference in New Issue
Block a user