Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Commit

Permalink
Move ensuring existence of directories for configuration files to Con…
Browse files Browse the repository at this point in the history
…figurationAttributeBase
  • Loading branch information
matkoch committed Nov 9, 2019
1 parent 790ab9e commit 9c5b5ab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 6 additions & 3 deletions source/Nuke.Common/CI/ConfigurationAttributeBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Utilities;
using Nuke.Common.Utilities.Collections;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;

namespace Nuke.Common.CI
Expand Down Expand Up @@ -58,10 +59,12 @@ public void OnAfterLogo(
if (!AutoGenerate || NukeBuild.IsServerBuild)
return;

GeneratedFiles.ForEach(EnsureExistingParentDirectory);

Logger.LogLevel = LogLevel.Trace;
var previousHashes = GeneratedFiles
.Where(File.Exists)
.ToDictionary(x => x, FileSystemTasks.GetFileHash);
.ToDictionary(x => x, GetFileHash);

var assembly = Assembly.GetEntryAssembly().NotNull("assembly != null");
ProcessTasks.StartProcess(
Expand All @@ -72,7 +75,7 @@ public void OnAfterLogo(
.AssertZeroExitCode();

var changedFiles = GeneratedFiles
.Where(x => FileSystemTasks.GetFileHash(x) != previousHashes.GetValueOrDefault(x))
.Where(x => GetFileHash(x) != previousHashes.GetValueOrDefault(x))
.Select(x => GetRelativePath(NukeBuild.RootDirectory, x)).ToList();

if (changedFiles.Count > 0)
Expand All @@ -96,7 +99,7 @@ public void OnBuildFinished(NukeBuild build)

private string GetCurrentHash()
{
return GeneratedFiles.Select(FileSystemTasks.GetFileHash).JoinComma();
return GeneratedFiles.Select(GetFileHash).JoinComma();
}

protected abstract HostType HostType { get; }
Expand Down
1 change: 0 additions & 1 deletion source/Nuke.Common/Utilities/CustomFileWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class CustomFileWriter : IDisposable

public CustomFileWriter(string filename, int indentationFactor, FileMode fileMode = FileMode.Create)
{
FileSystemTasks.EnsureExistingParentDirectory(filename);
_fileStream = File.Open(filename, fileMode);
_streamWriter = new StreamWriter(_fileStream);

Expand Down

0 comments on commit 9c5b5ab

Please sign in to comment.