wrapper: write stdout/stderr data to stream when received

This commit is contained in:
Austin Valle 2024-04-25 10:23:13 -04:00
parent 1f0219f06b
commit 003aea7b7b
4 changed files with 38 additions and 17 deletions

View file

@ -21,9 +21,9 @@ async function checkTerraform () {
// This will fail if Terraform isn't found, which is what we want
await checkTerraform();
// Create listeners to receive output (in memory) as well
const stdout = new OutputListener();
const stderr = new OutputListener();
// Create listeners to receive output (in memory)
const stdout = new OutputListener(process.stdout);
const stderr = new OutputListener(process.stderr);
const listeners = {
stdout: stdout.listener,
stderr: stderr.listener
@ -38,10 +38,6 @@ async function checkTerraform () {
};
const exitCode = await exec(pathToCLI, args, options);
// Pass-through stdout/err as `exec` won't due to `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);