From 985d494a0f059e129c6e2172efe0d86941ae3454 Mon Sep 17 00:00:00 2001 From: Mozi <29089388+pzhlkj6612@users.noreply.github.com> Date: Wed, 26 May 2021 21:32:04 +0800 Subject: [PATCH] Print the error message from conf scripts at once (#41) Printing them line by line will generate a bunch of error messages on the summary page of GitHub Actions workflow. I think it's a bit annoying. Note that this change will also affect the format of the final output error message, but no information will be lost. --- index.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/index.js b/index.js index 08fd322..a5f9bd8 100644 --- a/index.js +++ b/index.js @@ -126,19 +126,17 @@ function main() { // If vsvars.bat is given an incorrect command line, it will print out // an error and *still* exit successfully. Parse out errors from output // which don't look like environment variables, and fail if appropriate. - var failed = false - for (let line of vcvars_output) { + const error_messages = vcvars_output.filter((line) => { if (line.match(/^\[ERROR.*\]/)) { - failed = true // Don't print this particular line which will be confusing in output. - if (line.match(/Error in script usage. The correct usage is:$/)) { - continue + if (!line.match(/Error in script usage. The correct usage is:$/)) { + return true } - core.error(line) } - } - if (failed) { - throw new Error('invalid parameters') + return false + }) + if (error_messages.length > 0) { + throw new Error('invalid parameters' + '\r\n' + error_messages.join('\r\n')) } // Convert old environment lines into a dictionary for easier lookup.