Skip to content

Commit a89f1c8

Browse files
authored
Fixed bug when using Find-AzUpgradeCommandReference -DirectoryPath #[121] (#122)
* bugfix * fix * fix test * upgrade version
1 parent 26e0b28 commit a89f1c8

File tree

5 files changed

+11
-13
lines changed

5 files changed

+11
-13
lines changed

Diff for: powershell-module/Az.Tools.Migration/Az.Tools.Migration.psd1

+2-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
RootModule = 'Az.Tools.Migration.psm1'
44

55
# Version number of this module.
6-
ModuleVersion = '2.0.0'
6+
ModuleVersion = '2.0.1'
77

88
# Supported PSEditions
99
CompatiblePSEditions = 'Core', 'Desktop'
@@ -108,16 +108,7 @@
108108
# IconUri = ''
109109

110110
# ReleaseNotes of this module
111-
ReleaseNotes = "* Supported AzureRM to Az 10.3 migration
112-
* `Get-AzUpgradeAliasSpec`
113-
* Parameter `ModuleVersion` now accept value 'latest' only [BreakingChange]
114-
* `Get-AzUpgradeCmdletSpec`
115-
* Parameter `ModuleName` removed` [BreakingChange]
116-
* Added switch parameters `AzureRM` and `Az`
117-
* Parameter `ModuleVersion` now accept value 'latest' only and has to be used with `Az` [BreakingChange]
118-
* `New-AzUpgradeModulePlan`
119-
* Parameter `ToAzVersion` now accept value 'latest' only [BreakingChange]
120-
* Parameter `FilePath` now accept relative file path"
111+
ReleaseNotes = "* Fixed bug when using `Find-AzUpgradeCommandReference -DirectoryPath` #[121]"
121112
}
122113
}
123114

Diff for: powershell-module/Az.Tools.Migration/Functions/Public/Find-AzUpgradeCommandReference.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ function Find-AzUpgradeCommandReference
9292
Process
9393
{
9494
$cmdStarted = Get-Date
95-
$FilePath = (Resolve-Path $FilePath).Path
9695

9796
if ($PSBoundParameters.ContainsKey('AzureRmModuleSpec') -eq $false)
9897
{
@@ -112,6 +111,7 @@ function Find-AzUpgradeCommandReference
112111
throw "File was not found or was not accessible: $FilePath"
113112
}
114113

114+
$FilePath = (Resolve-Path $FilePath).Path
115115
Write-Verbose -Message "Searching for AzureRM references in file: $FilePath"
116116
$foundCmdlets = Find-CmdletsInFile -FilePath $FilePath | Where-object -FilterScript { $AzureRmModuleSpec.ContainsKey($_.CommandName) -eq $true }
117117

@@ -138,6 +138,7 @@ function Find-AzUpgradeCommandReference
138138
throw "Directory was not found or was not accessible: $DirectoryPath"
139139
}
140140

141+
$DirectoryPath = (Resolve-Path $DirectoryPath).Path
141142
$filesToSearch = Get-ChildItem -Path $DirectoryPath -Recurse -Include *.ps1, *.psm1
142143
$commandCounter = 0
143144

Diff for: powershell-module/Az.Tools.Migration/Functions/Public/New-AzUpgradeModulePlan.ps1

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ function New-AzUpgradeModulePlan
122122
{
123123
$cmdStarted = Get-Date
124124

125-
$FilePath = (Resolve-Path $FilePath).Path
126125
$versionPath = Join-Path -Path $MyInvocation.MyCommand.Module.ModuleBase -ChildPath "\Resources\ModuleSpecs\Az\$ToAzVersion"
127126
$version = Get-ChildItem -Path $versionPath -Name
128127

@@ -131,6 +130,7 @@ function New-AzUpgradeModulePlan
131130

132131
if ($PSCmdlet.ParameterSetName -eq 'FromNewSearchByFile')
133132
{
133+
$FilePath = (Resolve-Path $FilePath).Path
134134
if ($PSBoundParameters.ContainsKey('AzureRmModuleSpec'))
135135
{
136136
Write-Verbose -Message "Searching for commands to upgrade, by file, with pre-loaded module spec."
@@ -144,6 +144,7 @@ function New-AzUpgradeModulePlan
144144
}
145145
elseif ($PSCmdlet.ParameterSetName -eq 'FromNewSearchByDirectory')
146146
{
147+
$DirectoryPath = (Resolve-Path $DirectoryPath).Path
147148
if ($PSBoundParameters.ContainsKey('AzureRmModuleSpec'))
148149
{
149150
Write-Verbose -Message "Searching for commands to upgrade, by directory, with pre-loaded module spec."

Diff for: powershell-module/Az.Tools.Migration/Tests/Functions/Public/Find-AzUpgradeCommandReference.tests.ps1

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ InModuleScope -ModuleName Az.Tools.Migration -ScriptBlock {
66
# arrange
77
Mock -CommandName Test-Path -MockWith { Write-Output -InputObject $true }
88

9+
Mock -CommandName Resolve-Path -MockWith { @{Path = $Path} }
10+
911
# ensure we don't send telemetry during tests.
1012
Mock -CommandName Send-MetricsIfDataCollectionEnabled -ModuleName Az.Tools.Migration -MockWith { }
1113

Diff for: powershell-module/ChangeLog.md

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
-->
2020
## Upcoming Release
2121

22+
## 2.0.1
23+
* Fixed bug when using `Find-AzUpgradeCommandReference -DirectoryPath` #[121]
24+
2225
## 2.0.0
2326
* Supported AzureRM to Az 10.3 migration
2427
* `Get-AzUpgradeAliasSpec`

0 commit comments

Comments
 (0)