From c7bab6f874a90c53ecf7e5c027cf93430c8aac17 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Fri, 13 Sep 2024 00:04:49 +0200 Subject: [PATCH] fix: clean go install output (#1102) --- dist/post_run/index.js | 7 ++++++- dist/run/index.js | 7 ++++++- src/install.ts | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 28a0666..68bec30 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -85322,7 +85322,12 @@ async function goInstall(versionConfig) { const res = await execShellCommand(`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, options); printOutput(res); // The output of `go install -n` when the binary is already installed is `touch `. - const lintPath = res.stderr.trimStart().trimEnd().split(` `, 2)[1]; + const lintPath = res.stderr + .split(/\r?\n/) + .map((v) => v.trimStart().trimEnd()) + .filter((v) => v.startsWith("touch ")) + .reduce((a, b) => a + b, "") + .split(` `, 2)[1]; core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`); return lintPath; } diff --git a/dist/run/index.js b/dist/run/index.js index 07025c2..ee0dd54 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -85322,7 +85322,12 @@ async function goInstall(versionConfig) { const res = await execShellCommand(`go install -n github.com/golangci/golangci-lint/cmd/golangci-lint@${versionConfig.TargetVersion}`, options); printOutput(res); // The output of `go install -n` when the binary is already installed is `touch `. - const lintPath = res.stderr.trimStart().trimEnd().split(` `, 2)[1]; + const lintPath = res.stderr + .split(/\r?\n/) + .map((v) => v.trimStart().trimEnd()) + .filter((v) => v.startsWith("touch ")) + .reduce((a, b) => a + b, "") + .split(` `, 2)[1]; core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`); return lintPath; } diff --git a/src/install.ts b/src/install.ts index a062143..658fb24 100644 --- a/src/install.ts +++ b/src/install.ts @@ -101,7 +101,12 @@ export async function goInstall(versionConfig: VersionConfig): Promise { printOutput(res) // The output of `go install -n` when the binary is already installed is `touch `. - const lintPath = res.stderr.trimStart().trimEnd().split(` `, 2)[1] + const lintPath = res.stderr + .split(/\r?\n/) + .map((v) => v.trimStart().trimEnd()) + .filter((v) => v.startsWith("touch ")) + .reduce((a, b) => a + b, "") + .split(` `, 2)[1] core.info(`Installed golangci-lint into ${lintPath} in ${Date.now() - startedAt}ms`)