@@ -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 };
0 commit comments