yavsc/src/Yavsc.Server/Models/IT/SourceCode/SingleCmdProjectBatch.cs

33 lines
1 KiB
C#
Raw Normal View History

2019-06-24 14:30:47 +01:00
using System.Diagnostics;
2018-09-07 16:19:30 +02:00
namespace Yavsc.Server.Models.IT.SourceCode
{
public abstract class SingleCmdProjectBatch : Batch<Project>
{
protected string _repositoryRootPath;
protected string _cmdPath ;
public SingleCmdProjectBatch (string repoRoot, string cmdPath)
{
_cmdPath = cmdPath;
_repositoryRootPath = repoRoot;
WorkingDir = _repositoryRootPath;
var fie = new DirectoryInfo(WorkingDir);
if (!fie.Exists)
throw new Exception ($"This directory doesn't exist: {WorkingDir},\nand cannot be used as a repository.");
}
2019-06-24 14:30:47 +01:00
public ProcessStartInfo CreateStartInfo(string workingDir)
{
var args = string.Join(" ", Args);
var info = new ProcessStartInfo
( _cmdPath, args )
{
WorkingDirectory = workingDir ?? WorkingDir,
RedirectStandardOutput = true,
UseShellExecute = false
};
return info;
}
2018-09-07 16:19:30 +02:00
}
}