Continue if no matches
This commit is contained in:
+9
-15
@@ -6,7 +6,7 @@ import { PackageCache } from '@github/dependency-submission-toolkit'
|
|||||||
|
|
||||||
import { parseGoModGraph, parseGoList } from './parse'
|
import { parseGoModGraph, parseGoList } from './parse'
|
||||||
|
|
||||||
export async function processGoGraph (
|
export async function processGoGraph(
|
||||||
goModDir: string,
|
goModDir: string,
|
||||||
directDependencies: Array<PackageURL>,
|
directDependencies: Array<PackageURL>,
|
||||||
indirectDependencies: Array<PackageURL>
|
indirectDependencies: Array<PackageURL>
|
||||||
@@ -51,21 +51,15 @@ export async function processGoGraph (
|
|||||||
* package */
|
* package */
|
||||||
const matches = cache.packagesMatching(matcher)
|
const matches = cache.packagesMatching(matcher)
|
||||||
|
|
||||||
console.log(
|
if (matches.length === 0) return
|
||||||
'matcher:',
|
|
||||||
matcher,
|
|
||||||
'parentPkg:',
|
|
||||||
parentPkg,
|
|
||||||
'childPkg:',
|
|
||||||
childPkg
|
|
||||||
)
|
|
||||||
if (matches.length !== 1) {
|
if (matches.length !== 1) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'assertion failed: expected one package in cache with namespace+name. ' +
|
'assertion failed: expected no more than one package in cache with namespace+name. ' +
|
||||||
'Found: ' +
|
'Found: ' +
|
||||||
JSON.stringify(matches) +
|
JSON.stringify(matches) +
|
||||||
'\n' +
|
'for ' +
|
||||||
`matcher: ${matcher} parentPkg: ${parentPkg} childPkg: ${childPkg}`
|
JSON.stringify(matcher)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// create the dependency relationship
|
// create the dependency relationship
|
||||||
@@ -87,7 +81,7 @@ const GO_DIRECT_DEPS_TEMPLATE =
|
|||||||
const GO_INDIRECT_DEPS_TEMPLATE =
|
const GO_INDIRECT_DEPS_TEMPLATE =
|
||||||
'{{define "M"}}{{if .Indirect}}{{.Path}}@{{.Version}}{{end}}{{end}}{{with .Module}}{{if not .Main}}{{if .Replace}}{{template "M" .Replace}}{{else}}{{template "M" .}}{{end}}{{end}}{{end}}'
|
'{{define "M"}}{{if .Indirect}}{{.Path}}@{{.Version}}{{end}}{{end}}{{with .Module}}{{if not .Main}}{{if .Replace}}{{template "M" .Replace}}{{else}}{{template "M" .}}{{end}}{{end}}{{end}}'
|
||||||
|
|
||||||
export async function processGoDirectDependencies (
|
export async function processGoDirectDependencies(
|
||||||
goModDir: string,
|
goModDir: string,
|
||||||
goBuildTarget: string
|
goBuildTarget: string
|
||||||
): Promise<Array<PackageURL>> {
|
): Promise<Array<PackageURL>> {
|
||||||
@@ -97,7 +91,7 @@ export async function processGoDirectDependencies (
|
|||||||
return processGoList(goModDir, goBuildTarget, GO_DIRECT_DEPS_TEMPLATE)
|
return processGoList(goModDir, goBuildTarget, GO_DIRECT_DEPS_TEMPLATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function processGoIndirectDependencies (
|
export async function processGoIndirectDependencies(
|
||||||
goModDir: string,
|
goModDir: string,
|
||||||
goBuildTarget: string
|
goBuildTarget: string
|
||||||
): Promise<Array<PackageURL>> {
|
): Promise<Array<PackageURL>> {
|
||||||
@@ -107,7 +101,7 @@ export async function processGoIndirectDependencies (
|
|||||||
return processGoList(goModDir, goBuildTarget, GO_INDIRECT_DEPS_TEMPLATE)
|
return processGoList(goModDir, goBuildTarget, GO_INDIRECT_DEPS_TEMPLATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function processGoList (
|
async function processGoList(
|
||||||
goModDir: string,
|
goModDir: string,
|
||||||
goBuildTarget: string,
|
goBuildTarget: string,
|
||||||
goListTemplate: string
|
goListTemplate: string
|
||||||
|
|||||||
Reference in New Issue
Block a user