Skip to content

Commit

Permalink
fix bug with wrapper and stdout (#27)
Browse files Browse the repository at this point in the history
* fix bug with wrapper and stdout
---------

Co-authored-by: mcalhoun <[email protected]>
  • Loading branch information
mcalhoun and mcalhoun authored Jan 8, 2024
1 parent d2ed397 commit ac26ea4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dist/wrapper/index.js

Large diffs are not rendered by default.

9 changes: 7 additions & 2 deletions src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const guardAtmosInstalled = async () => {
const args = process.argv.slice(2);
const options = {
listeners,
ignoreReturnCode: true
ignoreReturnCode: true,
silent: true // avoid printing command in stdout: https://github.com/actions/toolkit/issues/649
};

const exitCode = await exec(pathToCLI, args, options);
Expand All @@ -39,14 +40,18 @@ const guardAtmosInstalled = async () => {
core.debug(`stderr: ${stderr.contents}`);
core.debug(`exitcode: ${exitCode}`);

// Pass-through stdout/err as `exec` won't anymore because we are passing `silent: true` option
process.stdout.write(stdout.contents);
process.stderr.write(stderr.contents);

// Set outputs, result, exitcode, and stderr
core.setOutput("stdout", stdout.contents);
core.setOutput("stderr", stderr.contents);
core.setOutput("exitcode", exitCode.toString(10));

if (exitCode === 0 || exitCode === 2) {
// A exitCode of 0 is considered a success
// An exitCode of 2 may be returned when the '-detailed-exitcode' option is passed to terraform plan. This denotes
// An exitCode of 2 may be returned when the '-detailed-exitcode' option is passed to atmos terraform plan. This denotes
// Success with non-empty diff (changes present).
return;
}
Expand Down

0 comments on commit ac26ea4

Please sign in to comment.