@@ -17,28 +17,52 @@ parseDependents = function (contents: string) {
17
17
const entries : ParsedDependencies = { }
18
18
const repoName = splitStdoutArr [ 0 ] [ 0 ]
19
19
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
21
21
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 ] } `
24
26
25
27
const matchFound = line [ 0 ] . match ( repoName )
26
28
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' )
29
30
return
30
31
}
31
32
32
- if ( dependencyString in entries ) {
33
- entry = entries [ dependencyString ]
33
+ if ( targetPkg in entries ) {
34
+ targetEntry = entries [ targetPkg ]
34
35
} else {
35
- entry = new Entry ( dependencyString , 'indirect' )
36
- entries [ dependencyString ] = entry
36
+ targetEntry = new Entry ( targetPkg , 'indirect' )
37
+ entries [ targetPkg ] = targetEntry
37
38
}
38
39
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 )
40
48
} )
41
49
return entries
42
50
}
43
51
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