Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate the output content from CMD with the form feed character #40

Merged
merged 1 commit into from
May 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,18 @@ function main() {
const vcvars = `"${findVcvarsall()}" ${args.join(' ')}`
core.debug(`vcvars command-line: ${vcvars}`)

const old_environment = child_process.execSync(`set`, {shell: "cmd"}).toString().split('\r\n')
const new_environment = child_process.execSync(`${vcvars} && set`, {shell: "cmd"}).toString().split('\r\n')
const cmd_output_string = child_process.execSync(`set && cls && ${vcvars} && cls && set`, {shell: "cmd"}).toString()
const cmd_output_parts = cmd_output_string.split('\f')

const old_environment = cmd_output_parts[0].split('\r\n')
const vcvars_output = cmd_output_parts[1].split('\r\n')
const new_environment = cmd_output_parts[2].split('\r\n')

// 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 new_environment) {
for (let line of vcvars_output) {
if (line.match(/^\[ERROR.*\]/)) {
failed = true
// Don't print this particular line which will be confusing in output.
Expand Down