Skip to content

Commit

Permalink
Merge pull request #586 from WildernessLabs/dominique-FixTrimApplicat…
Browse files Browse the repository at this point in the history
…ionEdgeCase

Fix edge case where passed in configuration doesn't exist in app path.
  • Loading branch information
adrianstevens authored Jul 23, 2024
2 parents 12c04f2 + 8f6a8ea commit 1c15780
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
21 changes: 15 additions & 6 deletions Source/v2/Meadow.CLI/Commands/Current/App/AppTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,25 @@ internal static async Task<bool> TrimApplication(string path,

if (configuration is not null)
{
file = candidates
.Where(c => c.DirectoryName.IndexOf(configuration, StringComparison.OrdinalIgnoreCase) >= 0)
.OrderByDescending(c => c.LastWriteTime)
.First();
var foundConfiguration = candidates.Where(c => c.DirectoryName?.IndexOf(configuration, StringComparison.OrdinalIgnoreCase) >= 0);

if (file == null)
if (foundConfiguration.Count() == 0)
{
logger?.LogError($"{Strings.NoCompiledApplicationFound} at '{path}'");
logger?.LogError($"{Strings.NoCompiledApplicationFound} {Strings.WithConfiguration} '{configuration}' {Strings.At} '{path}'");
return false;
}
else
{
file = foundConfiguration
.OrderByDescending(c => c.LastWriteTime)
.First();

if (file == null)
{
logger?.LogError($"{Strings.NoCompiledApplicationFound} {Strings.At} '{path}'");
return false;
}
}
}
else
{
Expand Down
5 changes: 3 additions & 2 deletions Source/v2/Meadow.Cli/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ public static class Strings
public const string AppDeployFailed = "Application deploy failed";
public const string AppDeployedSuccessfully = "Application deployed successfully";
public const string AppTrimFailed = "Application trimming failed";
public const string WithConfiguration = "with configuration";
public const string At = "at";


public static class Telemetry
public static class Telemetry
{
public const string ConsentMessage = @$"
Let's improve the Meadow experience together
Expand Down

0 comments on commit 1c15780

Please sign in to comment.