feat: ported action definition from setup-terraform

Signed-off-by: Dmitry Kisler <admin@dkisler.com>
This commit is contained in:
Dmitry Kisler 2023-10-05 01:14:33 +02:00
parent c37e0c575a
commit 01bef202d2
No known key found for this signature in database
GPG key ID: 46C0A987D58548F6
19 changed files with 18728 additions and 3 deletions

View file

@ -0,0 +1,41 @@
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
/**
* Acts as a listener for @actions/exec, by capturing STDOUT and STDERR
* streams, and exposing them via a contents attribute.
*
* @example
* // Instantiate a new listener
* const listener = new OutputListener();
* // Register listener against STDOUT stream
* await exec.exec('ls', ['-ltr'], {
* listeners: {
* stdout: listener.listener
* }
* });
* // Log out STDOUT contents
* console.log(listener.contents);
*/
class OutputListener {
constructor () {
this._buff = [];
}
get listener () {
const listen = function listen (data) {
this._buff.push(data);
};
return listen.bind(this);
}
get contents () {
return this._buff
.map(chunk => chunk.toString())
.join('');
}
}
module.exports = OutputListener;