Skip to content

Commit

Permalink
issue #1663: switch to the interface for file system commands in run …
Browse files Browse the repository at this point in the history
…scripts post action
  • Loading branch information
AR-May committed Oct 15, 2020
1 parent d855e07 commit d667a95
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using Microsoft.TemplateEngine.Abstractions;
using Microsoft.TemplateEngine.Abstractions.PhysicalFileSystem;
using Microsoft.TemplateEngine.Utils;

namespace Microsoft.TemplateEngine.Cli.PostActionProcessors
Expand Down Expand Up @@ -29,7 +30,7 @@ public bool Process(IEngineEnvironmentSettings settings, IPostAction actionConfi

settings.Host.LogMessage(string.Format(LocalizableStrings.RunningCommand, actionConfig.Args["executable"] + " " + args));

string resolvedExecutablePath = ResolveExecutableFilePath(actionConfig.Args["executable"], outputBasePath);
string resolvedExecutablePath = ResolveExecutableFilePath(settings.Host.FileSystem, actionConfig.Args["executable"], outputBasePath);

System.Diagnostics.Process commandResult = System.Diagnostics.Process.Start(new ProcessStartInfo
{
Expand Down Expand Up @@ -60,12 +61,12 @@ public bool Process(IEngineEnvironmentSettings settings, IPostAction actionConfi
return allSucceeded;
}

private static string ResolveExecutableFilePath(string executableFileName, string outputBasePath)
private static string ResolveExecutableFilePath(IPhysicalFileSystem fileSystem, string executableFileName, string outputBasePath)
{
if (!string.IsNullOrEmpty(outputBasePath) && Directory.Exists(outputBasePath))
if (!string.IsNullOrEmpty(outputBasePath) && fileSystem.DirectoryExists(outputBasePath))
{
string executableCombinedFileName = Path.Combine(Path.GetFullPath(outputBasePath), executableFileName);
if (File.Exists(executableCombinedFileName))
if (fileSystem.FileExists(executableCombinedFileName))
{
return executableCombinedFileName;
}
Expand Down

0 comments on commit d667a95

Please sign in to comment.