From 3722cc50dd7c9cbd0f4c1749ea61b3188ae3de7e Mon Sep 17 00:00:00 2001 From: noamd-legit <74864790+noamd-legit@users.noreply.github.com> Date: Sun, 10 Sep 2023 18:58:29 +0300 Subject: [PATCH] fix: action extra param (#251) * fixed the handling of the extra arg * rename token --- index.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/index.js b/index.js index 8a26dcea..04ed3b3a 100644 --- a/index.js +++ b/index.js @@ -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) @@ -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 = []; @@ -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; }