import { Transform, type TransformCallback } from "stream"; import { Command } from "./command"; export class RunTransform extends Transform { private command: Command; constructor(template: string, options?: any) { super({ objectMode: true }); this.command = new Command(template, options || {}); } _transform(chunk: any, encoding: BufferEncoding, callback: TransformCallback): void { const stdout = this.command.exec(chunk, callback); this.push(stdout); } exec(stdin?: any, callback?: any) { this.write(stdin, callback); this.end(); return this; } } export default (template: string, options?: any) => new RunTransform(template, options);