Skip to content

Commit

Permalink
fix: action extra param (#251)
Browse files Browse the repository at this point in the history
* fixed the handling of the extra arg

* rename token
  • Loading branch information
noamd-legit authored Sep 10, 2023
1 parent ad4fa1b commit 3722cc5
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function executeLegitify(token, args, uploadCodeScanning) {
myError += data.toString();
},
};
options.env = { GITHUB_TOKEN: token };
options.env = { SCM_TOKEN: token };
options.silent = true
const isPrivate = await isPrivateRepo(token)
core.setOutput("is_private", isPrivate)
Expand Down Expand Up @@ -132,6 +132,11 @@ async function fetchLegitifyReleaseUrl(baseVersion) {
}
}

function breakStringToParams(str) {
const pattern = /(-{1,2}\S+)(?:\s+((?!\s*-).+?)(?=\s+-{1,2}|\s*$))?/g;
return str.match(pattern)
}

function generateAnalyzeArgs(repo, owner) {
let args = [];

Expand All @@ -144,25 +149,24 @@ function generateAnalyzeArgs(repo, owner) {
if (process.env["analyze_self_only"] === "true") {
args.push("--repo");
args.push(repo);
return args;
}

if (process.env["repositories"] !== "") {
} else if (process.env["repositories"] !== "") {
args.push("--repo");
args.push(process.env["repositories"]);
return args;
} else {
args.push("--org");
args.push(owner);
}

args.push("--org");
args.push(owner);

if (process.env["ignore-policies-file"] !== "") {
args.push("--ignore-policies-file");
args.push(process.env["ignore-policies-file"]);
return args;
}

args.push(process.env["extra"])
const extra = process.env["extra"]
if (extra !== "") {
const splitArgs = breakStringToParams(extra)
args.push(...splitArgs)
}

return args;
}
Expand Down

0 comments on commit 3722cc5

Please sign in to comment.