@@ -17,28 +17,52 @@ parseDependents = function (contents: string) {
1717 const entries : ParsedDependencies = { }
1818 const repoName = splitStdoutArr [ 0 ] [ 0 ]
1919 splitStdoutArr . forEach ( ( line : string [ ] ) => {
20- if ( line . length < 2 || line === undefined ) return // skip empty lines
20+ if ( line === undefined || line . length < 2 ) return // skip empty lines
2121
22- let entry : Entry
23- let dependencyString = `pkg:golang/${ line [ 0 ] } `
22+ let targetEntry : Entry
23+ const targetPkg = `pkg:golang/${ line [ 0 ] } `
24+ let dependencyEntry : Entry
25+ const dependencyPkg = `pkg:golang/${ line [ 1 ] } `
2426
2527 const matchFound = line [ 0 ] . match ( repoName )
2628 if ( matchFound && matchFound . index != null ) {
27- dependencyString = `pkg:golang/${ line [ 1 ] } `
28- entries [ dependencyString ] = new Entry ( dependencyString , 'direct' )
29+ entries [ dependencyPkg ] = new Entry ( dependencyPkg , 'direct' )
2930 return
3031 }
3132
32- if ( dependencyString in entries ) {
33- entry = entries [ dependencyString ]
33+ if ( targetPkg in entries ) {
34+ targetEntry = entries [ targetPkg ]
3435 } else {
35- entry = new Entry ( dependencyString , 'indirect' )
36- entries [ dependencyString ] = entry
36+ targetEntry = new Entry ( targetPkg , 'indirect' )
37+ entries [ targetPkg ] = targetEntry
3738 }
3839
39- entry . addDependency ( new Entry ( `pkg:golang/${ line [ 1 ] } ` , 'indirect' ) )
40+ if ( dependencyPkg in entries ) {
41+ dependencyEntry = entries [ dependencyPkg ]
42+ } else {
43+ dependencyEntry = new Entry ( dependencyPkg , 'indirect' )
44+ entries [ dependencyPkg ] = dependencyEntry
45+ }
46+
47+ targetEntry . addDependency ( dependencyEntry )
4048 } )
4149 return entries
4250}
4351
44- run ( parseDependents , undefined , 'go mod graph' )
52+ const metadata = {
53+ foo : 1.0 ,
54+ bar : false ,
55+ baz : 'somethingsomething' ,
56+ nullz : null
57+ }
58+ const detector = {
59+ name : 'Typescript Snapshot Detector' ,
60+ url : 'https://github.com/github/dependency_snapshot_action' ,
61+ version : '0.0.1'
62+ }
63+
64+ run (
65+ parseDependents ,
66+ { command : 'go mod graph' } ,
67+ { metadata, detector }
68+ )
0 commit comments