Skip to content

Commit d20adb1

Browse files
committed
address PR feedback and remove unused imports
1 parent 0535aff commit d20adb1

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

src/code/LocalServerApiCalls.cs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using System.Xml;
1313
using System.Net;
1414
using System.Management.Automation;
15-
using System.Runtime.ExceptionServices;
1615

1716
namespace Microsoft.PowerShell.PSResourceGet.Cmdlets
1817
{
@@ -652,7 +651,7 @@ private Hashtable GetMetadataFromNupkg(string packageName, string packagePath, s
652651
string psd1FilePath = String.Empty;
653652
string ps1FilePath = String.Empty;
654653
string nuspecFilePath = String.Empty;
655-
GetMetadataFilesFromPath(tempDiscoveryPath, packageName, out psd1FilePath, out ps1FilePath, out nuspecFilePath);
654+
Utils.GetMetadataFilesFromPath(tempDiscoveryPath, packageName, out psd1FilePath, out ps1FilePath, out nuspecFilePath);
656655

657656
List<string> pkgTags = new List<string>();
658657

@@ -1084,35 +1083,6 @@ private string[] GetCmdsOrDSCTags(string[] tags, bool isSearchingForCommands)
10841083
return cmdDSCTags.ToArray();
10851084
}
10861085

1087-
private void GetMetadataFilesFromPath(string dirPath, string packageName, out string psd1FilePath, out string ps1FilePath, out string nuspecFilePath)
1088-
{
1089-
psd1FilePath = String.Empty;
1090-
ps1FilePath = String.Empty;
1091-
nuspecFilePath = String.Empty;
1092-
1093-
var discoveredFiles = Directory.GetFiles(dirPath, "*.*", SearchOption.AllDirectories);
1094-
string pkgNamePattern = $"{packageName}*";
1095-
Regex rgx = new(pkgNamePattern, RegexOptions.IgnoreCase);
1096-
foreach (var file in discoveredFiles)
1097-
{
1098-
if (rgx.IsMatch(file))
1099-
{
1100-
if (file.EndsWith("psd1"))
1101-
{
1102-
psd1FilePath = file;
1103-
}
1104-
else if (file.EndsWith("nuspec"))
1105-
{
1106-
nuspecFilePath = file;
1107-
}
1108-
else if (file.EndsWith("ps1"))
1109-
{
1110-
ps1FilePath = file;
1111-
}
1112-
}
1113-
}
1114-
}
1115-
11161086
#endregion
11171087
}
11181088
}

src/code/Utils.cs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Net;
21
// Copyright (c) Microsoft Corporation. All rights reserved.
32
// Licensed under the MIT License.
43

@@ -15,12 +14,13 @@
1514
using System.Runtime.InteropServices;
1615
using Microsoft.PowerShell.Commands;
1716
using Microsoft.PowerShell.PSResourceGet.Cmdlets;
17+
using System.Net;
1818
using System.Net.Http;
1919
using System.Globalization;
2020
using System.Security;
2121
using Azure.Core;
2222
using Azure.Identity;
23-
using System.Threading.Tasks;
23+
using System.Text.RegularExpressions;
2424
using System.Threading;
2525

2626
namespace Microsoft.PowerShell.PSResourceGet.UtilClasses
@@ -1171,6 +1171,34 @@ internal static HashSet<string> GetInstalledPackages(List<string> pathsToSearch,
11711171
return pkgsInstalledOnMachine;
11721172
}
11731173

1174+
internal static void GetMetadataFilesFromPath(string dirPath, string packageName, out string psd1FilePath, out string ps1FilePath, out string nuspecFilePath)
1175+
{
1176+
psd1FilePath = String.Empty;
1177+
ps1FilePath = String.Empty;
1178+
nuspecFilePath = String.Empty;
1179+
1180+
var discoveredFiles = Directory.GetFiles(dirPath, "*.*", SearchOption.AllDirectories);
1181+
string pkgNamePattern = $"{packageName}*";
1182+
Regex rgx = new(pkgNamePattern, RegexOptions.IgnoreCase);
1183+
foreach (var file in discoveredFiles)
1184+
{
1185+
if (rgx.IsMatch(file))
1186+
{
1187+
if (file.EndsWith("psd1"))
1188+
{
1189+
psd1FilePath = file;
1190+
}
1191+
else if (file.EndsWith("nuspec"))
1192+
{
1193+
nuspecFilePath = file;
1194+
}
1195+
else if (file.EndsWith("ps1"))
1196+
{
1197+
ps1FilePath = file;
1198+
}
1199+
}
1200+
}
1201+
}
11741202
#endregion
11751203

11761204
#region PSDataFile parsing

0 commit comments

Comments
 (0)