|
1 | | -import * as core from "@actions/core"; |
2 | | -import { run } from "@github/dependency-submission-toolkit"; |
3 | | -import { ProcessDependenciesContent } from "@github/dependency-submission-toolkit/dist/processor"; |
4 | | -import { parseDependents } from "./go_mod_parser"; |
5 | | -import * as path from "path"; |
6 | | -import * as process from "process"; |
7 | | -import execa from "execa"; |
| 1 | +import * as core from '@actions/core' |
| 2 | +import { run } from '@github/dependency-submission-toolkit' |
| 3 | +import { ProcessDependenciesContent } from '@github/dependency-submission-toolkit/dist/processor' |
| 4 | +import { parseDependents } from './go_mod_parser' |
| 5 | +import * as path from 'path' |
| 6 | +import * as process from 'process' |
| 7 | +import execa from 'execa' |
8 | 8 |
|
9 | | -const parseDependentsFunc: ProcessDependenciesContent = parseDependents; |
| 9 | +const parseDependentsFunc: ProcessDependenciesContent = parseDependents |
10 | 10 |
|
11 | 11 | // Set the detector information provided from the action workflow input |
12 | 12 | const detector = { |
13 | | - name: core.getInput("detector-name"), |
14 | | - url: core.getInput("detector-url"), |
15 | | - version: core.getInput("detector-version"), |
16 | | -}; |
| 13 | + name: core.getInput('detector-name'), |
| 14 | + url: core.getInput('detector-url'), |
| 15 | + version: core.getInput('detector-version') |
| 16 | +} |
17 | 17 |
|
18 | | -async function searchForFile(filename: string) { |
19 | | - console.log(`searching for ${filename} in ${process.cwd()}`); |
| 18 | +async function searchForFile (filename: string) { |
| 19 | + console.log(`searching for ${filename} in ${process.cwd()}`) |
20 | 20 |
|
21 | | - const { stdout } = await execa("find", [process.cwd(), "-name", filename]); |
| 21 | + const { stdout } = await execa('find', [process.cwd(), '-name', filename]) |
22 | 22 |
|
23 | 23 | const dirs = stdout |
24 | | - .split("\n") |
| 24 | + .split('\n') |
25 | 25 | .filter((s) => s.length > 0) |
26 | 26 | // remove the file name |
27 | 27 | .map((filename) => path.dirname(filename)) |
28 | 28 | // map to absolute path |
29 | | - .map((pathname) => path.resolve(process.cwd(), pathname)); |
| 29 | + .map((pathname) => path.resolve(process.cwd(), pathname)) |
30 | 30 |
|
31 | | - return dirs; |
| 31 | + return dirs |
32 | 32 | } |
33 | 33 |
|
34 | 34 | // Enumerate directories |
35 | | -async function detect() { |
36 | | - const goModPaths = await searchForFile("go.mod"); |
| 35 | +async function detect () { |
| 36 | + const goModPaths = await searchForFile('go.mod') |
37 | 37 |
|
38 | 38 | // If provided, set the metadata provided from the action workflow input |
39 | | - const metadataInput = core.getInput("metadata"); |
| 39 | + const metadataInput = core.getInput('metadata') |
40 | 40 |
|
41 | 41 | goModPaths.forEach((path) => { |
42 | | - process.chdir(path); |
43 | | - console.log(`Running go mod graph in ${path}`); |
| 42 | + process.chdir(path) |
| 43 | + console.log(`Running go mod graph in ${path}`) |
44 | 44 | if (metadataInput.length < 1) { |
45 | | - run(parseDependentsFunc, { command: "go mod graph" }, { detector }); |
| 45 | + run(parseDependentsFunc, { command: 'go mod graph' }, { detector }) |
46 | 46 | } else { |
47 | | - const metadata = JSON.parse(metadataInput); |
| 47 | + const metadata = JSON.parse(metadataInput) |
48 | 48 | run( |
49 | 49 | parseDependentsFunc, |
50 | | - { command: "go mod graph" }, |
| 50 | + { command: 'go mod graph' }, |
51 | 51 | { metadata, detector } |
52 | | - ); |
| 52 | + ) |
53 | 53 | } |
54 | | - }); |
| 54 | + }) |
55 | 55 | } |
56 | 56 |
|
57 | | -detect(); |
| 57 | +detect() |
0 commit comments