mirror of
https://github.com/opentofu/setup-opentofu.git
synced 2026-11-29 19:44:21 +01:00
Streaming when using tofu_wrapper (#75)
Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
This commit is contained in:
1 parent
04ba7507e2
commit
e95ccdd206
4 files changed
+20
-18
No files matched your search
@@ -9,7 +9,8 @@
|
||||
*
|
||||
* @example
|
||||
* // Instantiate a new listener
|
||||
* const listener = new OutputListener();
|
||||
* // stream is used to write the data before waiting for the listener to complete
|
||||
* const listener = new OutputListener(stream);
|
||||
* // Register listener against STDOUT stream
|
||||
* await exec.exec('ls', ['-ltr'], {
|
||||
* listeners: {
|
||||
@@ -20,12 +21,14 @@
|
||||
* console.log(listener.contents);
|
||||
*/
|
||||
class OutputListener {
|
||||
constructor () {
|
||||
constructor (stream) {
|
||||
this._buff = [];
|
||||
this._stream = stream;
|
||||
}
|
||||
|
||||
get listener () {
|
||||
const listen = function listen (data) {
|
||||
this._stream.write(data);
|
||||
this._buff.push(data);
|
||||
};
|
||||
return listen.bind(this);
|
||||
|
||||
Reference in new issue
Block a user