Skeleton for license validation.

This commit is contained in:
Federico Builes
2022-06-06 20:32:46 +02:00
parent 8c646c1c91
commit bccacf9708
6 changed files with 115 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import {Change, ChangeSchema} from './schemas'
export function hasInvalidLicenses(
changes: Array<Change>,
allowLicenses: Array<string> | undefined,
failLicenses: Array<string> | undefined
): Array<Change> {
let disallowed: Change[] = []
if (allowLicenses === undefined) {
allowLicenses = []
}
if (failLicenses === undefined) {
failLicenses = []
}
for (const change of changes) {
let license = change.license
// TODO: be loud about unknown licenses
if (license === null) {
continue
}
if (allowLicenses.includes(license)) {
disallowed.push(change)
}
}
return disallowed
}
export function printLicensesError(changes: Array<Change>): void {
return
}