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

Commit e426705

Browse files
authored
Remove prefix from go target
1 parent 0506777 commit e426705

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,27 @@ async function detect () {
3636
}
3737
const goModDir = path.dirname(goModPath)
3838

39-
const goBuildTarget = path.normalize(core.getInput('go-build-target'))
39+
let goBuildTarget = path.normalize(core.getInput('go-build-target'))
4040
if (goBuildTarget !== 'all' && goBuildTarget !== '...') {
4141
if (!fs.existsSync(goBuildTarget)) {
4242
throw new Error(`The build target '${goBuildTarget}' does not exist`)
4343
}
4444
if (goModDir !== '.' && !goBuildTarget.startsWith(goModDir)) {
45-
throw new Error(
46-
`The build target ${goBuildTarget} is not a sub-directory of ${goModDir}`
47-
)
45+
if (goBuildTarget.startsWith(goModDir)) {
46+
goBuildTarget = goBuildTarget.replace(goModDir, '')
47+
} else {
48+
throw new Error(
49+
`The build target ${goBuildTarget} is not a sub-directory of ${goModDir}`
50+
)
51+
}
4852
}
4953
}
5054

5155
const metadataInput = core.getInput('metadata')
52-
go(goModDir, goBuildTarget, metadataInput)
56+
processGoTarget(goModDir, goBuildTarget, metadataInput)
5357
}
5458

55-
function go (goModDir: string, goBuildTarget: string, metadataInput?: string) {
59+
function processGoTarget (goModDir: string, goBuildTarget: string, metadataInput?: string) {
5660
process.chdir(goModDir)
5761
console.log(
5862
`Running go package detection in ${process.cwd()} on build target ${goBuildTarget}`

0 commit comments

Comments
 (0)