mirror of
https://github.com/PowerShell/PowerShell.git
synced 2024-11-24 02:04:07 +08:00
Remove unncessary check for Paths.count > 0 as there is code later to use the current (#5596)
Remove unnecessary check for Paths.count > 0 as there is code later to use the current working directory since -Path is not a mandatory parameter. Updated ShouldProcess to output the internal action on adding paths rather than the user action (which is the cmdlet name). Updated tests to not specify -Path Fix #5594
This commit is contained in:
parent
baa0a28a21
commit
b69ff717ab
@ -95,7 +95,7 @@ namespace Microsoft.PowerShell.Commands
|
||||
{
|
||||
foreach (PathInfo tempPath in SessionState.Path.GetResolvedPSPathFromPSPath(p))
|
||||
{
|
||||
if (ShouldProcess(tempPath.ProviderPath))
|
||||
if (ShouldProcess("Including path " + tempPath.ProviderPath, "", ""))
|
||||
{
|
||||
paths.Add(tempPath.ProviderPath);
|
||||
}
|
||||
@ -103,17 +103,16 @@ namespace Microsoft.PowerShell.Commands
|
||||
}
|
||||
}
|
||||
|
||||
// We add 'paths.Count > 0' to support 'ShouldProcess()'
|
||||
if (paths.Count > 0 )
|
||||
string drive = null;
|
||||
|
||||
// resolve catalog destination Path
|
||||
if (!SessionState.Path.IsPSAbsolute(catalogFilePath, out drive) && !System.IO.Path.IsPathRooted(catalogFilePath))
|
||||
{
|
||||
string drive = null;
|
||||
|
||||
// resolve catalog destination Path
|
||||
if (!SessionState.Path.IsPSAbsolute(catalogFilePath, out drive) && !System.IO.Path.IsPathRooted(catalogFilePath))
|
||||
{
|
||||
catalogFilePath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(catalogFilePath);
|
||||
}
|
||||
catalogFilePath = SessionState.Path.GetUnresolvedProviderPathFromPSPath(catalogFilePath);
|
||||
}
|
||||
|
||||
if (ShouldProcess(catalogFilePath))
|
||||
{
|
||||
PerformAction(paths, catalogFilePath);
|
||||
}
|
||||
}
|
||||
|
@ -233,11 +233,14 @@ Describe "Test suite for NewFileCatalogAndTestFileCatalogCmdlets" -Tags "CI" {
|
||||
try
|
||||
{
|
||||
copy-item "$testDataPath\UserConfigProv" $env:temp -Recurse -ErrorAction SilentlyContinue
|
||||
$null = New-FileCatalog -Path $env:temp\UserConfigProv\ -CatalogFilePath $catalogPath -CatalogVersion 1.0
|
||||
$result = Test-FileCatalog -Path $env:temp\UserConfigProv\ -CatalogFilePath $catalogPath
|
||||
Push-Location "$env:TEMP\UserConfigProv"
|
||||
# When -Path is not specified, it should use current directory
|
||||
$null = New-FileCatalog -CatalogFilePath $catalogPath -CatalogVersion 1.0
|
||||
$result = Test-FileCatalog -CatalogFilePath $catalogPath
|
||||
}
|
||||
finally
|
||||
{
|
||||
Pop-Location
|
||||
Remove-Item "$catalogPath" -Force -ErrorAction SilentlyContinue
|
||||
Remove-Item "$env:temp\UserConfigProv\" -Force -ErrorAction SilentlyContinue -Recurse
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user