@best/console-stream
Version:
Best stdout stream wrapper
36 lines • 957 B
JavaScript
;
/*
* Copyright (c) 2019, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.proxyStream = proxyStream;
function proxyStream(stream, isInteractive) {
const _originalWrite = stream.write;
let proxyBuffer = '';
if (isInteractive) {
stream.write = (msg) => {
proxyBuffer += msg;
};
}
return {
unproxyStream() {
proxyBuffer = '';
stream.write = _originalWrite;
},
readBuffer() {
return proxyBuffer;
},
clearBuffer() {
proxyBuffer = '';
},
writeBuffer(msg) {
if (msg) {
proxyBuffer += msg;
}
},
};
}
//# sourceMappingURL=proxy-stream.js.map