Skip to content

Commit

Permalink
Add CakeExecuteScript parent cake.exe ToolPath fallback
Browse files Browse the repository at this point in the history
* Fixes #1119
  • Loading branch information
devlead authored and gep13 committed Jul 25, 2016
1 parent c29e1d9 commit e9ae9e9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Cake.Common/Tools/Cake/CakeRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public sealed class CakeRunner : Tool<CakeSettings>
private readonly ICakeEnvironment _environment;
private readonly IFileSystem _fileSystem;
private readonly IGlobber _globber;
private static readonly IEnumerable<FilePath> _executingAssemblyToolPaths = new FilePath[] { System.Reflection.Assembly.GetEntryAssembly().Location };

/// <summary>
/// Initializes a new instance of the <see cref="CakeRunner"/> class.
Expand Down Expand Up @@ -151,18 +152,18 @@ protected override IEnumerable<FilePath> GetAlternativeToolPaths(CakeSettings se

if (!_environment.Platform.IsUnix())
{
return Enumerable.Empty<FilePath>();
return _executingAssemblyToolPaths;
}

if (!_fileSystem.Exist(new DirectoryPath(homebrewCakePath)))
{
return Enumerable.Empty<FilePath>();
return _executingAssemblyToolPaths;
}

var files = _globber.GetFiles(homebrewCakePath + "**/Cake.exe");
var filePaths = files as FilePath[] ?? files.ToArray();
return filePaths.Length == 0
? Enumerable.Empty<FilePath>()
? _executingAssemblyToolPaths
: filePaths.OrderByDescending(f => f.FullPath);
}
}
Expand Down

0 comments on commit e9ae9e9

Please sign in to comment.