mirror of
https://github.com/hashicorp/setup-terraform.git
synced 2025-12-16 16:42:35 +00:00
wrapper: Write stdout/stderr data to stream when received (#410)
* wrapper: write stdout/stderr data to stream when received * add a delay test * temp comment * uncomment actions * add changelog
This commit is contained in:
parent
5f32e8acaf
commit
99441ecd44
7 changed files with 85 additions and 18 deletions
17
dist/index1.js
vendored
17
dist/index1.js
vendored
|
|
@ -27599,13 +27599,18 @@ module.exports = {
|
|||
* console.log(listener.contents);
|
||||
*/
|
||||
class OutputListener {
|
||||
constructor () {
|
||||
constructor (streamWriter) {
|
||||
this._buff = [];
|
||||
this._streamWriter = streamWriter;
|
||||
}
|
||||
|
||||
get listener () {
|
||||
const listen = function listen (data) {
|
||||
this._buff.push(data);
|
||||
|
||||
if (this._streamWriter) {
|
||||
this._streamWriter.write(data);
|
||||
}
|
||||
};
|
||||
return listen.bind(this);
|
||||
}
|
||||
|
|
@ -27946,9 +27951,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
|
||||
|
|
@ -27963,10 +27968,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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue