mirror of https://github.com/abpframework/abp.git
committed by
GitHub
2 changed files with 64 additions and 0 deletions
@ -0,0 +1,54 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
|
||||
|
namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps |
||||
|
{ |
||||
|
public class RemoveProjectFromTyeStep : ProjectBuildPipelineStep |
||||
|
{ |
||||
|
private readonly string _name; |
||||
|
|
||||
|
public RemoveProjectFromTyeStep(string name) |
||||
|
{ |
||||
|
_name = name; |
||||
|
} |
||||
|
|
||||
|
public override void Execute(ProjectBuildContext context) |
||||
|
{ |
||||
|
var tyeFile = context.Files.FirstOrDefault(f => f.Name == "/tye.yaml"); |
||||
|
|
||||
|
if (tyeFile == null) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
var lines = tyeFile.GetLines(); |
||||
|
var newLines = new List<string>(); |
||||
|
|
||||
|
var nameLine = $"- name:"; |
||||
|
var isOneOfTargetLines = false; |
||||
|
|
||||
|
foreach (var line in lines) |
||||
|
{ |
||||
|
if (line.Equals($"{nameLine} {_name}")) |
||||
|
{ |
||||
|
isOneOfTargetLines = true; |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
if (line.StartsWith(nameLine)) |
||||
|
{ |
||||
|
isOneOfTargetLines = false; |
||||
|
} |
||||
|
|
||||
|
if (!isOneOfTargetLines) |
||||
|
{ |
||||
|
newLines.Add(line); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
tyeFile.SetContent(String.Join(Environment.NewLine, newLines)); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue