From 92c027dbfad72584cf5d707a8d189ae3b5ed29d6 Mon Sep 17 00:00:00 2001 From: Michael J Mulligan Date: Thu, 1 Apr 2021 15:25:35 +0100 Subject: [PATCH 1/2] 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`) From e8074422061458d359875b46a1804d3a82f35155 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Sun, 4 Apr 2021 02:48:01 +0200 Subject: [PATCH 2/2] review --- dist/post_run/index.js | 8 ++++++-- dist/run/index.js | 8 ++++++-- src/run.ts | 11 ++++++++--- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index b6d8b3587f..585a64f14a 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -6811,8 +6811,12 @@ function runLint(lintPath, patchPath) { } const userArgs = core.getInput(`args`); const addedArgs = []; - const userArgNamesRegex = /(?<=(^|\s)-+\b)([^\s=]+)(?==)/ig; - const userArgNames = new Set(userArgs.match(userArgNamesRegex)); + const userArgNames = new Set(userArgs + .trim() + .split(/\s+/) + .map((arg) => arg.split(`=`)[0]) + .filter((arg) => arg.startsWith(`-`)) + .map((arg) => arg.replace(/^-+/, ``))); 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 a223c8b943..29f29e542f 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -6821,8 +6821,12 @@ function runLint(lintPath, patchPath) { } const userArgs = core.getInput(`args`); const addedArgs = []; - const userArgNamesRegex = /(?<=(^|\s)-+\b)([^\s=]+)(?==)/ig; - const userArgNames = new Set(userArgs.match(userArgNamesRegex)); + const userArgNames = new Set(userArgs + .trim() + .split(/\s+/) + .map((arg) => arg.split(`=`)[0]) + .filter((arg) => arg.startsWith(`-`)) + .map((arg) => arg.replace(/^-+/, ``))); 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 ad659b732e..ffcd3e7f52 100644 --- a/src/run.ts +++ b/src/run.ts @@ -121,9 +121,14 @@ async function runLint(lintPath: string, patchPath: string): Promise { const userArgs = core.getInput(`args`) const addedArgs: string[] = [] - const userArgNamesRegex = /(?<=(^|\s)-+\b)([^\s=]+)(?==)/ig - const userArgNames = new Set(userArgs.match(userArgNamesRegex)) - + const userArgNames = new Set( + userArgs + .trim() + .split(/\s+/) + .map((arg) => arg.split(`=`)[0]) + .filter((arg) => arg.startsWith(`-`)) + .map((arg) => arg.replace(/^-+/, ``)) + ) if (userArgNames.has(`out-format`)) { throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`) }