Skip to content

Commit fbe77c9

Browse files
authored
File Append Method (#881)
1 parent 73a112b commit fbe77c9

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Add File.AppendAsync method

src/ModularPipelines.GitHub/GitHubMarkdownSummaryGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public async Task OnEndAsync(IPipelineHookContext pipelineContext, PipelineSumma
3333
return;
3434
}
3535

36-
await pipelineContext.FileSystem.GetFile(stepSummaryVariable).WriteAsync($"{mermaid}\n\n{table}\n\n{_afterPipelineLogger.GetOutput()}{exception}");
36+
await pipelineContext.FileSystem.GetFile(stepSummaryVariable).AppendAsync($"{mermaid}\n\n{table}\n\n{_afterPipelineLogger.GetOutput()}{exception}");
3737
}
3838

3939
private async Task<string> GetException(PipelineSummary pipelineSummary)

src/ModularPipelines/FileSystem/File.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ public async Task WriteAsync(Stream contents, CancellationToken cancellationToke
9898

9999
await contents.CopyToAsync(fileStream, cancellationToken);
100100
}
101+
102+
public Task AppendAsync(string contents, CancellationToken cancellationToken = default)
103+
{
104+
ModuleLogger.Current.LogInformation("Writing to File: {Path}", this);
105+
106+
return System.IO.File.AppendAllTextAsync(Path, contents, cancellationToken);
107+
}
108+
109+
public Task AppendAsync(IEnumerable<string> contents, CancellationToken cancellationToken = default)
110+
{
111+
ModuleLogger.Current.LogInformation("Writing to File: {Path}", this);
112+
113+
return System.IO.File.AppendAllLinesAsync(Path, contents, cancellationToken);
114+
}
101115

102116
/// <inheritdoc cref="FileSystemInfo.Exists"/>>
103117
public bool Exists => FileInfo.Exists;

0 commit comments

Comments
 (0)