Skip to content

Commit 812daa7

Browse files
committed
Update CreateMappings.ps1 to encode mapping file in UTF8 and fix mapping bug
1 parent 6fa973c commit 812daa7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

tools/CreateMappings.ps1

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@ $cmdlets | ForEach-Object {
2929
# Try to match this cmdlet with at least one rule.
3030
$possibleBetterMatch = @($rules | Where-Object { $cmdlet -cmatch ".*$($_.Regex).*" })[0];
3131

32-
# Look for a better match, but ensure that the groups match.
33-
if(($matchedRule.Group -ne $null) -and ($matchedRule.Group -eq $possibleBetterMatch.Group)) {
32+
# Look for the best match.
33+
if(
34+
# Did not find a match on the folder, but found a match on the cmdlet.
35+
(($matchedRule -eq $null) -and ($possibleBetterMatch -ne $null)) -or
36+
# Found a match on the module path, but found a better match for the cmdlet (`group` field agrees).
37+
(($matchedRule.Group -ne $null) -and ($matchedRule.Group -eq $possibleBetterMatch.Group)))
38+
{
3439
$matchedRule = $possibleBetterMatch;
3540
}
3641

@@ -44,8 +49,8 @@ $cmdlets | ForEach-Object {
4449
};
4550

4651
# Write to files.
47-
$warnings | ConvertTo-Json | Out-File $WarningFile;
48-
$results | ConvertTo-Json | Out-File $OutputFile;
52+
$warnings | ConvertTo-Json | Out-File $WarningFile -Encoding utf8;
53+
$results | ConvertTo-Json | Out-File $OutputFile -Encoding utf8;
4954

5055
# Print conclusion.
5156
Write-Host ""
@@ -55,4 +60,4 @@ Write-Host ""
5560
if($warnings.Count -gt 0) {
5661
Write-Host "$($warnings.Count) cmdlets could not be mapped and were placed in 'Other': $($WarningFile)." -ForegroundColor Yellow;
5762
throw "Some cmdlets could not be properly mapped to a documentation grouping: $($warnings -join ", "). Please add a mapping rule to $(Resolve-Path -Path $RulesFile).";
58-
}
63+
}

0 commit comments

Comments
 (0)