Skip to content

Commit

Permalink
use regex to properly get package files for local repos especially on…
Browse files Browse the repository at this point in the history
… Linux
  • Loading branch information
anamnavi committed Oct 11, 2024
1 parent 78a0cf6 commit 843211b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/code/LocalServerApiCalls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -652,13 +652,15 @@ private Hashtable GetMetadataFromNupkg(string packageName, string packagePath, s
var currentFiles = Directory.GetFiles(tempDiscoveryPath);

string psd1FilePath = String.Empty;
string ps1FilePath = String.Empty;
string nuspecFilePath = String.Empty;
string pkgNamePattern = $"{packageName}*";
Regex rgx = new(pkgNamePattern, RegexOptions.IgnoreCase);
foreach (var x in currentFiles)
{
if (rgx.IsMatch(x))
{
_cmdletPassedIn.WriteVerbose("file is a match: " + x);
if (x.EndsWith("psd1"))
{
psd1FilePath = x;
Expand All @@ -667,15 +669,13 @@ private Hashtable GetMetadataFromNupkg(string packageName, string packagePath, s
{
nuspecFilePath = x;
}
else if (x.EndsWith("ps1"))
{
ps1FilePath = x;
}
}
_cmdletPassedIn.WriteVerbose($"file found: " + x);

}

foreach (var x in currentFiles)
{
_cmdletPassedIn.WriteVerbose($"file found: " + x);

}

var files = Directory.EnumerateFiles(tempDiscoveryPath, "*.*", SearchOption.AllDirectories).Where(
Expand All @@ -688,7 +688,7 @@ private Hashtable GetMetadataFromNupkg(string packageName, string packagePath, s
}

// string psd1FilePath = Path.Combine(tempDiscoveryPath, $"{packageName}.psd1");
string ps1FilePath = Path.Combine(tempDiscoveryPath, $"{packageName}.ps1");
// string ps1FilePath = Path.Combine(tempDiscoveryPath, $"{packageName}.ps1");
// string nuspecFilePath = Path.Combine(tempDiscoveryPath, $"{packageName}.nuspec");

List<string> pkgTags = new List<string>();
Expand Down

0 comments on commit 843211b

Please sign in to comment.