Skip to content

Commit

Permalink
🔺 don't fail on missing check functions (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
GantMan authored Apr 2, 2018
1 parent eb8020d commit 3641d3a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions __tests__/command_helpers/checkRequirementPlugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ describe('checkRequirement Plugins', () => {
expect(result).toEqual(['Boooo failed check'])
})

test('CUSTOM and missing check function OK', async () => {
mockContext.addPlugin({
name: 'Empty Plugin',
description: 'I help test plugins',
rules: {
emptyDude: {}
}
})
const rule = toPairs({
TestRequirement: [{ rule: 'custom', plugin: 'Empty Plugin', name: 'emptyDude' }],
})[0]
const result = await checkRequirement(rule, mockContext)
expect(result).toEqual([[]])
})

test('failed to find plugin', async () => {
const rule = toPairs({
TestRequirement: [{ rule: 'custom', plugin: 'I do not exist', name: 'checkSecondThing' }],
Expand Down
2 changes: 2 additions & 0 deletions src/extensions/functions/checkRequirement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ module.exports = async (
case 'custom':
const customPluginRule = findPluginInfo(rule, context)
if (customPluginRule.success) {
// No check provided, we jet
if (!customPluginRule.plugin.check) return []
const customResult = await customPluginRule.plugin.check(rule, context)
if (customResult && customResult.pass) {
return addSuccess(customResult.message)
Expand Down

0 comments on commit 3641d3a

Please sign in to comment.