这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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