UNPKG

conventional-changelog-conventionalcommits

Version:
34 lines (27 loc) 598 B
function hasIntersection(a, b) { if (!a || !b) { return false } let listA = a let listB = b if (!Array.isArray(listA)) { listA = [listA] } if (!Array.isArray(listB)) { listB = [listB] } return listA.some(item => listB.includes(item)) } export function matchScope(config = {}, commit) { const { scope: targetScope, scopeOnly = false } = config const includesScope = hasIntersection( commit.scope?.split(','), targetScope ) return !targetScope || (scopeOnly && includesScope) || (!scopeOnly && (!commit.scope || includesScope)) }