import { CvsResource } from "../../bll/entities/cvsresources/cvsresource" ; import { GetStagedFileContentLength } from "./GetStagedFileContentLength" ; import { ReadableSet } from "../../bll/utils/readableset" ; import { Utils } from "../../bll/utils/utils" ; import * as stream from "stream" ; import { CpProxy } from "../../bll/moduleproxies/cp-proxy" ; export class GetStagedFileContentStream { constructor ( private readonly workspaceRootPath , private readonly gitPath , private readonly cpProxy , private readonly cvsResource , private readonly getStagedFileContentLengthCommand ) { } public async execute ( ) { const relativePath = Utils . getNormalizedRelativePath ( this . cvsResource , this . workspaceRootPath ) ; const commandOptions = this . getCommandOptions ( relativePath ) ; const streamLength = await this . getStagedFileContentLengthCommand . execute ( ) ; const showFileStream = this . cpProxy . spawn ( `${ this . gitPath }` , commandOptions ) . stdout ; return { stream : showFileStream , length : streamLength } ; } private getCommandOptions ( relativePath ) { return [ `-C` , `${ this . workspaceRootPath }` , `show` , `:${ relativePath }` ] ; } }