Streaming when using tofu_wrapper (#75)
Some checks failed
Continuous Integration / Check dist/ directory (push) Has been cancelled
Continuous Integration / Test (push) Has been cancelled
Setup OpenTofu / OpenTofu Version Files (push) Has been cancelled
Setup OpenTofu / OpenTofu Versions (push) Has been cancelled
Setup OpenTofu / OpenTofu Arguments (push) Has been cancelled
Setup OpenTofu / OpenTofu Run Local (push) Has been cancelled
Setup OpenTofu / OpenTofu Cloud Credentials (push) Has been cancelled
Setup OpenTofu / OpenTofu Enterprise Credentials (push) Has been cancelled
Setup OpenTofu / OpenTofu No Credentials (push) Has been cancelled

Signed-off-by: Diogenes Fernandes <diofeher@gmail.com>
This commit is contained in:
Diógenes Fernandes 2025-12-17 12:29:27 -03:00 committed by GitHub
parent 04ba7507e2
commit e95ccdd206
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 18 deletions

View file

@ -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);