Skip to content

Commit

Permalink
Ignore removed changes in license checker
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jul 13, 2022
1 parent bced8aa commit c5d7bdc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
18 changes: 18 additions & 0 deletions __tests__/licenses.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,21 @@ test('it fails all license checks when allow is provided an empty array', async
})
expect(invalidChanges.length).toBe(2)
})

test('it does not fail if a license outside the allow list is found in removed changes', async () => {
const changes: Changes = [
{...npmChange, change_type: 'removed'},
{...rubyChange, change_type: 'removed'}
]
const [invalidChanges, _] = getDeniedLicenseChanges(changes, {allow: ['BSD']})
expect(invalidChanges).toStrictEqual([])
})

test('it does not fail if a license inside the deny list is found in removed changes', async () => {
const changes: Changes = [
{...npmChange, change_type: 'removed'},
{...rubyChange, change_type: 'removed'}
]
const [invalidChanges, _] = getDeniedLicenseChanges(changes, {deny: ['BSD']})
expect(invalidChanges).toStrictEqual([])
})
4 changes: 4 additions & 0 deletions src/licenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export function getDeniedLicenseChanges(
const unknown: Change[] = []

for (const change of changes) {
if (change.change_type === 'removed') {
continue
}

const license = change.license
if (license === null) {
unknown.push(change)
Expand Down

0 comments on commit c5d7bdc

Please sign in to comment.