From 92c027dbfad72584cf5d707a8d189ae3b5ed29d6 Mon Sep 17 00:00:00 2001 From: Michael J Mulligan Date: Thu, 1 Apr 2021 15:25:35 +0100 Subject: [PATCH] Extract and don't mangle User Args. --- dist/post_run/index.js | 10 ++-------- dist/run/index.js | 10 ++-------- src/run.ts | 10 ++-------- 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index f97447b542..b6d8b3587f 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -6811,14 +6811,8 @@ function runLint(lintPath, patchPath) { } const userArgs = core.getInput(`args`); const addedArgs = []; - const userArgNames = new Set(); - userArgs - .split(/\s/) - .map((arg) => arg.split(`=`)[0]) - .filter((arg) => arg.startsWith(`-`)) - .forEach((arg) => { - userArgNames.add(arg.replace(`-`, ``)); - }); + const userArgNamesRegex = /(?<=(^|\s)-+\b)([^\s=]+)(?==)/ig; + const userArgNames = new Set(userArgs.match(userArgNamesRegex)); if (userArgNames.has(`out-format`)) { throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`); } diff --git a/dist/run/index.js b/dist/run/index.js index d455344ea7..a223c8b943 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -6821,14 +6821,8 @@ function runLint(lintPath, patchPath) { } const userArgs = core.getInput(`args`); const addedArgs = []; - const userArgNames = new Set(); - userArgs - .split(/\s/) - .map((arg) => arg.split(`=`)[0]) - .filter((arg) => arg.startsWith(`-`)) - .forEach((arg) => { - userArgNames.add(arg.replace(`-`, ``)); - }); + const userArgNamesRegex = /(?<=(^|\s)-+\b)([^\s=]+)(?==)/ig; + const userArgNames = new Set(userArgs.match(userArgNamesRegex)); if (userArgNames.has(`out-format`)) { throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`); } diff --git a/src/run.ts b/src/run.ts index 66c7dbe9e6..ad659b732e 100644 --- a/src/run.ts +++ b/src/run.ts @@ -121,14 +121,8 @@ async function runLint(lintPath: string, patchPath: string): Promise { const userArgs = core.getInput(`args`) const addedArgs: string[] = [] - const userArgNames = new Set() - userArgs - .split(/\s/) - .map((arg) => arg.split(`=`)[0]) - .filter((arg) => arg.startsWith(`-`)) - .forEach((arg) => { - userArgNames.add(arg.replace(`-`, ``)) - }) + const userArgNamesRegex = /(?<=(^|\s)-+\b)([^\s=]+)(?==)/ig + const userArgNames = new Set(userArgs.match(userArgNamesRegex)) if (userArgNames.has(`out-format`)) { throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)