Skip to content

Commit c5426bf

Browse files
authored
Separate output content from CMD with form feed (#40)
The command "cls" will produce a '\f' (0x0c, page break or form feed) character.
1 parent 100402d commit c5426bf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,18 @@ function main() {
116116
const vcvars = `"${findVcvarsall()}" ${args.join(' ')}`
117117
core.debug(`vcvars command-line: ${vcvars}`)
118118

119-
const old_environment = child_process.execSync(`set`, {shell: "cmd"}).toString().split('\r\n')
120-
const new_environment = child_process.execSync(`${vcvars} && set`, {shell: "cmd"}).toString().split('\r\n')
119+
const cmd_output_string = child_process.execSync(`set && cls && ${vcvars} && cls && set`, {shell: "cmd"}).toString()
120+
const cmd_output_parts = cmd_output_string.split('\f')
121+
122+
const old_environment = cmd_output_parts[0].split('\r\n')
123+
const vcvars_output = cmd_output_parts[1].split('\r\n')
124+
const new_environment = cmd_output_parts[2].split('\r\n')
121125

122126
// If vsvars.bat is given an incorrect command line, it will print out
123127
// an error and *still* exit successfully. Parse out errors from output
124128
// which don't look like environment variables, and fail if appropriate.
125129
var failed = false
126-
for (let line of new_environment) {
130+
for (let line of vcvars_output) {
127131
if (line.match(/^\[ERROR.*\]/)) {
128132
failed = true
129133
// Don't print this particular line which will be confusing in output.

0 commit comments

Comments
 (0)