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.