|
1 |
| -import { run } from "@github/dependency-snapshot-action"; |
| 1 | +import { run } from '@github/dependency-snapshot-action' |
2 | 2 | import {
|
3 | 3 | Entry,
|
4 | 4 | ParsedDependencies,
|
5 |
| - ProcessDependenciesContent, |
6 |
| -} from "@github/dependency-snapshot-action/dist/processor"; |
| 5 | + ProcessDependenciesContent |
| 6 | +} from '@github/dependency-snapshot-action/dist/processor' |
7 | 7 |
|
8 |
| -let parseDependents: ProcessDependenciesContent; |
| 8 | +let parseDependents: ProcessDependenciesContent |
9 | 9 |
|
10 | 10 | // eslint-disable-next-line prefer-const
|
11 | 11 | parseDependents = function (contents: string) {
|
12 |
| - const stdoutArr: string[] = contents.split("\n"); |
| 12 | + const stdoutArr: string[] = contents.split('\n') |
13 | 13 | const splitStdoutArr: string[][] = stdoutArr.map(function (line) {
|
14 |
| - return line.split(" "); |
15 |
| - }); |
| 14 | + return line.split(' ') |
| 15 | + }) |
16 | 16 |
|
17 |
| - const entries: ParsedDependencies = {}; |
18 |
| - const repoName = splitStdoutArr[0][0]; |
| 17 | + const entries: ParsedDependencies = {} |
| 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.length < 2 || line === undefined) return // skip empty lines |
21 | 21 |
|
22 |
| - let entry: Entry; |
23 |
| - let dependencyString = `pkg:golang/${line[0]}`; |
| 22 | + let entry: Entry |
| 23 | + let dependencyString = `pkg:golang/${line[0]}` |
24 | 24 |
|
25 |
| - const matchFound = line[0].match(repoName); |
| 25 | + const matchFound = line[0].match(repoName) |
26 | 26 | if (matchFound && matchFound.index != null) {
|
27 |
| - dependencyString = `pkg:golang/${line[1]}`; |
28 |
| - entries[dependencyString] = new Entry(dependencyString, "direct"); |
29 |
| - return; |
| 27 | + dependencyString = `pkg:golang/${line[1]}` |
| 28 | + entries[dependencyString] = new Entry(dependencyString, 'direct') |
| 29 | + return |
30 | 30 | }
|
31 | 31 |
|
32 | 32 | if (dependencyString in entries) {
|
33 |
| - entry = entries[dependencyString]; |
| 33 | + entry = entries[dependencyString] |
34 | 34 | } else {
|
35 |
| - entry = new Entry(dependencyString, "indirect"); |
36 |
| - entries[dependencyString] = entry; |
| 35 | + entry = new Entry(dependencyString, 'indirect') |
| 36 | + entries[dependencyString] = entry |
37 | 37 | }
|
38 | 38 |
|
39 |
| - entry.addDependency(new Entry(`pkg:golang/${line[1]}`, "indirect")); |
40 |
| - }); |
41 |
| - return entries; |
42 |
| -}; |
| 39 | + entry.addDependency(new Entry(`pkg:golang/${line[1]}`, 'indirect')) |
| 40 | + }) |
| 41 | + return entries |
| 42 | +} |
43 | 43 |
|
44 |
| -run(parseDependents, undefined, "go mod graph"); |
| 44 | +run(parseDependents, undefined, 'go mod graph') |
0 commit comments