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

Commit 659e82b

Browse files
authored
i hate checking in build artifacts >:[
1 parent e426705 commit 659e82b

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

dist/index.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,20 +70,25 @@ function detect() {
7070
throw new Error(`${goModPath} is not a go.mod file or does not exist!`);
7171
}
7272
const goModDir = path.dirname(goModPath);
73-
const goBuildTarget = path.normalize(core.getInput('go-build-target'));
73+
let goBuildTarget = path.normalize(core.getInput('go-build-target'));
7474
if (goBuildTarget !== 'all' && goBuildTarget !== '...') {
7575
if (!fs_1.default.existsSync(goBuildTarget)) {
7676
throw new Error(`The build target '${goBuildTarget}' does not exist`);
7777
}
7878
if (goModDir !== '.' && !goBuildTarget.startsWith(goModDir)) {
79-
throw new Error(`The build target ${goBuildTarget} is not a sub-directory of ${goModDir}`);
79+
if (goBuildTarget.startsWith(goModDir)) {
80+
goBuildTarget = goBuildTarget.replace(goModDir, '');
81+
}
82+
else {
83+
throw new Error(`The build target ${goBuildTarget} is not a sub-directory of ${goModDir}`);
84+
}
8085
}
8186
}
8287
const metadataInput = core.getInput('metadata');
83-
go(goModDir, goBuildTarget, metadataInput);
88+
processGoTarget(goModDir, goBuildTarget, metadataInput);
8489
});
8590
}
86-
function go(goModDir, goBuildTarget, metadataInput) {
91+
function processGoTarget(goModDir, goBuildTarget, metadataInput) {
8792
process.chdir(goModDir);
8893
console.log(`Running go package detection in ${process.cwd()} on build target ${goBuildTarget}`);
8994
const options = { detector };

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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ async function detect () {
5656
processGoTarget(goModDir, goBuildTarget, metadataInput)
5757
}
5858

59-
function processGoTarget (goModDir: string, goBuildTarget: string, metadataInput?: string) {
59+
function processGoTarget (
60+
goModDir: string,
61+
goBuildTarget: string,
62+
metadataInput?: string
63+
) {
6064
process.chdir(goModDir)
6165
console.log(
6266
`Running go package detection in ${process.cwd()} on build target ${goBuildTarget}`

0 commit comments

Comments
 (0)