Skip to content
This repository was archived by the owner on Jun 16, 2022. It is now read-only.

Commit e982d1c

Browse files
committed
Add logic to populate metadata if provided by action workflow input
1 parent ab60d22 commit e982d1c

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

dist/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,21 @@ parseDependents = function (contents) {
7272
});
7373
return entries;
7474
};
75-
const metadata = JSON.parse(core.getInput('metadata'));
75+
// Set the detector information provided from the action workflow input
7676
const detector = {
7777
name: core.getInput('detector-name'),
7878
url: core.getInput('detector-url'),
7979
version: core.getInput('detector-version')
8080
};
81-
(0, dependency_snapshot_action_1.run)(parseDependents, { command: 'go mod graph' }, { metadata, detector });
81+
// If provided, set the metadata provided from the action workflow input
82+
const metadataInput = core.getInput('metadata');
83+
if (metadataInput === undefined) {
84+
(0, dependency_snapshot_action_1.run)(parseDependents, { command: 'go mod graph' }, { detector });
85+
}
86+
else {
87+
const metadata = JSON.parse(metadataInput);
88+
(0, dependency_snapshot_action_1.run)(parseDependents, { command: 'go mod graph' }, { metadata, detector });
89+
}
8290

8391

8492
/***/ }),

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,19 @@ parseDependents = function (contents: string) {
5050
return entries
5151
}
5252

53-
const metadata = JSON.parse(core.getInput('metadata'))
53+
// Set the detector information provided from the action workflow input
5454
const detector = {
5555
name: core.getInput('detector-name'),
5656
url: core.getInput('detector-url'),
5757
version: core.getInput('detector-version')
5858
}
5959

60-
run(parseDependents, { command: 'go mod graph' }, { metadata, detector })
60+
// If provided, set the metadata provided from the action workflow input
61+
const metadataInput = core.getInput('metadata')
62+
63+
if (metadataInput === undefined) {
64+
run(parseDependents, { command: 'go mod graph' }, { detector })
65+
} else {
66+
const metadata = JSON.parse(metadataInput)
67+
run(parseDependents, { command: 'go mod graph' }, { metadata, detector })
68+
}

0 commit comments

Comments
 (0)