complete test suite conversions; simplify fn name
This commit is contained in:
+5
-3
@@ -5,7 +5,7 @@ import * as core from '@actions/core'
|
||||
import * as z from 'zod'
|
||||
import {ConfigurationOptions, ConfigurationOptionsSchema} from './schemas'
|
||||
import {octokitClient} from './utils'
|
||||
import {isValidSPDX} from './spdx'
|
||||
import {isValid} from './spdx'
|
||||
|
||||
type ConfigurationOptionsPartial = Partial<ConfigurationOptions>
|
||||
|
||||
@@ -114,10 +114,12 @@ function validateLicenses(
|
||||
return
|
||||
}
|
||||
|
||||
const invalid_licenses = licenses.filter(license => !isValidSPDX(license))
|
||||
const invalid_licenses = licenses.filter(license => !isValid(license))
|
||||
|
||||
if (invalid_licenses.length > 0) {
|
||||
throw new Error(`Invalid license(s) in ${key}: ${invalid_licenses}`)
|
||||
throw new Error(
|
||||
`Invalid license(s) in ${key}: ${invalid_licenses.join(', ')}`
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@ import spdxSatisfies from 'spdx-satisfies'
|
||||
import {Change, Changes} from './schemas'
|
||||
import {octokitClient} from './utils'
|
||||
import {parsePURL} from './purl'
|
||||
import {isValidSPDX} from './spdx'
|
||||
import {isValid} from './spdx'
|
||||
|
||||
/**
|
||||
* Loops through a list of changes, filtering and returning the
|
||||
@@ -166,7 +166,7 @@ const setGHLicenses = async (changes: Change[]): Promise<Change[]> => {
|
||||
// Currently Dependency Graph licenses are truncated to 255 characters
|
||||
// This possibly makes them invalid spdx ids
|
||||
const truncatedDGLicense = (license: string): boolean =>
|
||||
license.length === 255 && !isValidSPDX(license)
|
||||
license.length === 255 && !isValid(license)
|
||||
|
||||
async function groupChanges(
|
||||
changes: Changes
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ export function satisfies(
|
||||
}
|
||||
|
||||
// can be a single license or an SPDX expression
|
||||
export function isValidSPDX(spdxExpr: string): boolean {
|
||||
export function isValid(spdxExpr: string): boolean {
|
||||
try {
|
||||
parse(spdxExpr)
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user