Skip to content

Commit b7fee27

Browse files
author
Sergei Vorobev
committed
Expand aliases in platyPS.psm1
1 parent 843f322 commit b7fee27

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

src/platyPS/platyPS.psm1

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ function New-MarkdownHelp
155155

156156
if ($PSCmdlet.ParameterSetName -eq 'FromCommand')
157157
{
158-
$command | % {
158+
$command | ForEach-Object {
159159
if (-not (Get-Command $_ -EA SilentlyContinue))
160160
{
161161
throw "Command $_ not found in the session."
@@ -175,7 +175,7 @@ function New-MarkdownHelp
175175
$iterator = $MamlFile
176176
}
177177

178-
$iterator | % {
178+
$iterator | ForEach-Object {
179179
if ($PSCmdlet.ParameterSetName -eq 'FromModule')
180180
{
181181
if (-not (GetCommands -AsNames -module $_))
@@ -198,7 +198,7 @@ function New-MarkdownHelp
198198

199199
GetMamlObject -MamlFile $_ | ProcessMamlObjectToFile
200200

201-
$CmdletNames += GetMamlObject -MamlFile $_ | % {$_.Name}
201+
$CmdletNames += GetMamlObject -MamlFile $_ | ForEach-Object {$_.Name}
202202
}
203203

204204
if($WithModulePage)
@@ -245,7 +245,7 @@ function Get-MarkdownMetadata
245245
}
246246
else # FromFile)
247247
{
248-
GetMarkdowFilesFromPath $Path -IncludeModulePage | % {
248+
GetMarkdowFilesFromPath $Path -IncludeModulePage | ForEach-Object {
249249
$md = Get-Content -Raw $_.FullName
250250
[Markdown.MAML.Parser.MarkdownParser]::GetYamlMetadata($md) # yeild
251251
}
@@ -287,15 +287,15 @@ function Update-MarkdownHelpSchema
287287

288288
end
289289
{
290-
$markdown = $MarkdownFiles | % {
291-
cat -Raw $_.FullName
290+
$markdown = $MarkdownFiles | ForEach-Object {
291+
Get-Content -Raw $_.FullName
292292
}
293293

294294
$model = GetMamlModelImpl $markdown -PreserveFormatting
295295
$parseMode = GetParserMode -PreserveFormatting
296296
$r = New-Object -TypeName Markdown.MAML.Renderer.MarkdownV2Renderer -ArgumentList $parseMode
297297

298-
$model | % {
298+
$model | ForEach-Object {
299299
$name = $_.Name
300300
# TODO: can we pass some metadata here?
301301
# skipYamlHeader -eq $false
@@ -358,11 +358,11 @@ function Update-MarkdownHelp
358358
}
359359

360360

361-
$MarkdownFiles | % {
361+
$MarkdownFiles | ForEach-Object {
362362
$file = $_
363363

364364
$filePath = $file.FullName
365-
$oldMarkdown = cat -Raw $filePath
365+
$oldMarkdown = Get-Content -Raw $filePath
366366
$oldModels = GetMamlModelImpl $oldMarkdown -PreserveFormatting
367367

368368
if ($oldModels.Count -gt 1)
@@ -445,7 +445,7 @@ function Update-MarkdownHelpModule
445445
# the idea is to find module name from landing page when it's available
446446
if ($h.$script:MODULE_PAGE_MODULE_NAME)
447447
{
448-
$module = $h.$script:MODULE_PAGE_MODULE_NAME | Select -First 1
448+
$module = $h.$script:MODULE_PAGE_MODULE_NAME | Select-Object -First 1
449449
log "Determined module name for $modulePath as $moduleName"
450450
}
451451

@@ -466,7 +466,7 @@ function Update-MarkdownHelpModule
466466
}
467467

468468
$updatedCommands = $affectedFiles.BaseName
469-
$allCommands | % {
469+
$allCommands | ForEach-Object {
470470
if ( -not ($updatedCommands -contains $_) )
471471
{
472472
log "Creating new markdown for command $_"
@@ -520,7 +520,7 @@ function New-ExternalHelp
520520

521521
end
522522
{
523-
$MarkdownFiles | % {
523+
$MarkdownFiles | ForEach-Object {
524524
Write-Verbose "[New-ExternalHelp] Input markdown file $_"
525525
}
526526

@@ -529,7 +529,7 @@ function New-ExternalHelp
529529
if ($IsOutputContainer)
530530
{
531531
$defaultPath = Join-Path $OutputPath $script:DEFAULT_MAML_XML_OUTPUT_NAME
532-
$groups = $MarkdownFiles | group {
532+
$groups = $MarkdownFiles | Group-Object {
533533
$h = Get-MarkdownMetadata -Path $_.FullName
534534
if ($h -and $h[$script:EXTERNAL_HELP_FILE_YAML_HEADER])
535535
{
@@ -545,11 +545,11 @@ function New-ExternalHelp
545545
}
546546
else
547547
{
548-
$groups = $MarkdownFiles | group { $OutputPath }
548+
$groups = $MarkdownFiles | Group-Object { $OutputPath }
549549
}
550550

551551
foreach ($group in $groups) {
552-
$maml = GetMamlModelImpl ( $group.Group | % { cat -Raw $_.FullName } )
552+
$maml = GetMamlModelImpl ( $group.Group | ForEach-Object { Get-Content -Raw $_.FullName } )
553553
$xml = $r.MamlModelToString($maml, $false) # skipPreambula is not used
554554
$outPath = $group.Name # group name
555555
Write-Verbose "Writing external help to $outPath"
@@ -580,7 +580,7 @@ function Get-HelpPreview
580580
}
581581

582582
# this is Resolve-Path that resolves mounted drives (i.e. good for tests)
583-
$MamlFilePath = (ls $MamlFilePath).FullName
583+
$MamlFilePath = (Get-ChildItem $MamlFilePath).FullName
584584

585585
# Read the malm file
586586
$xml = [xml](Get-Content $MamlFilePath -Raw -ea SilentlyContinue)
@@ -595,7 +595,7 @@ function Get-HelpPreview
595595
$MamlCopyPath = [System.IO.Path]::GetTempFileName()
596596
try
597597
{
598-
cp $MamlFilePath $MamlCopyPath
598+
Copy-Item $MamlFilePath $MamlCopyPath
599599
foreach ($command in $xml.helpItems.command.details.name)
600600
{
601601
$thisDefinition = @"
@@ -630,7 +630,7 @@ Microsoft.PowerShell.Core\Export-ModuleMember -Function @()
630630
}
631631
finally
632632
{
633-
rm $MamlCopyPath
633+
Remove-Item $MamlCopyPath
634634
}
635635
}
636636
}
@@ -844,14 +844,14 @@ function GetMarkdowFilesFromPath
844844

845845
$MarkdownFiles = @()
846846
if ($Path) {
847-
$Path | % {
847+
$Path | ForEach-Object {
848848
if (Test-Path -PathType Leaf $_)
849849
{
850850
$MarkdownFiles += Get-ChildItem $_
851851
}
852852
elseif (Test-Path -PathType Container $_)
853853
{
854-
$MarkdownFiles += ls $_ -Filter $filter
854+
$MarkdownFiles += Get-ChildItem $_ -Filter $filter
855855
}
856856
else
857857
{
@@ -889,7 +889,7 @@ function GetMamlModelImpl
889889
# we need to pass it into .NET IEnumerable<MamlCommand> API
890890
$res = New-Object 'System.Collections.Generic.List[Markdown.MAML.Model.MAML.MamlCommand]'
891891

892-
$markdown | % {
892+
$markdown | ForEach-Object {
893893
$schema = GetSchemaVersion $_
894894
$p = NewMarkdownParser -PreserveFormatting:$PreserveFormatting
895895
$t = NewModelTransformer -schema $schema
@@ -900,7 +900,7 @@ function GetMamlModelImpl
900900
$maml = $t.NodeModelToMamlModel($model)
901901

902902
# flatten
903-
$maml | % { $res.Add($_) }
903+
$maml | ForEach-Object { $res.Add($_) }
904904
}
905905

906906
return @(,$res)
@@ -989,7 +989,7 @@ function UpdateMamlObject
989989
}
990990

991991
# Online Version URL
992-
if (-not ($MamlCommandObject.Links | ? {$_.LinkName -eq 'Online Version:'} )) {
992+
if (-not ($MamlCommandObject.Links | Where-Object {$_.LinkName -eq 'Online Version:'} )) {
993993
$mamlLink = New-Object -TypeName Markdown.MAML.Model.MAML.MamlLink
994994
$mamlLink.LinkName = 'Online Version:'
995995
if ($OnlineVersionUrl)
@@ -1137,8 +1137,8 @@ function GetHelpFileName
11371137

11381138
# overwise, lets guess it
11391139
$module = @($CommandInfo.Module) + ($CommandInfo.Module.NestedModules) |
1140-
? {$_.ModuleType -ne 'Manifest'} |
1141-
? {$_.ExportedCommands.Keys -contains $CommandInfo.Name}
1140+
Where-Object {$_.ModuleType -ne 'Manifest'} |
1141+
Where-Object {$_.ExportedCommands.Keys -contains $CommandInfo.Name}
11421142

11431143
if (-not $module)
11441144
{
@@ -1149,7 +1149,7 @@ function GetHelpFileName
11491149
if ($module.Count -gt 1)
11501150
{
11511151
Write-Warning "[GetHelpFileName] Found $($module.Count) modules for $($CommandInfo.Name)"
1152-
$module = $module | Select -First 1
1152+
$module = $module | Select-Object -First 1
11531153
}
11541154

11551155
$moduleItem = Get-Item -Path $module.Path
@@ -1250,7 +1250,7 @@ function NewModuleLandingPage
12501250
$Content += "---`r`n`r`n# $ModuleName Module`r`n## Description`r`n"
12511251
$Content += "{{Manually Enter Description Here}}`r`n`r`n## $ModuleName Cmdlets`r`n"
12521252

1253-
$CmdletNames | % {
1253+
$CmdletNames | ForEach-Object {
12541254
$Content += "### [" + $_ + "](" + $_ + ".md)`r`n{{Manually Enter $_ Description Here}}`r`n`r`n"
12551255
}
12561256

@@ -1362,7 +1362,7 @@ function GetMamlObject
13621362
#Provides Name, CommandType, and Empty Module name from MAML generated module in the $command object.
13631363
#Otherwise loads the results from Get-Command <Cmdlet> into the $command object
13641364

1365-
$HelpCollection | % {
1365+
$HelpCollection | ForEach-Object {
13661366

13671367
$Help = $_
13681368

@@ -1549,7 +1549,7 @@ function ConvertPsObjectsToMamlModel
15491549
[Markdown.MAML.Model.MAML.MamlParameter]$ParameterObject
15501550
)
15511551

1552-
$HelpEntry = $Help.parameters.parameter | WHERE {$_.Name -eq $ParameterObject.Name}
1552+
$HelpEntry = $Help.parameters.parameter | Where-Object {$_.Name -eq $ParameterObject.Name}
15531553

15541554
$ParameterObject.DefaultValue = $HelpEntry.defaultValue
15551555
$ParameterObject.VariableLength = $HelpEntry.variableLength -eq 'True'
@@ -1571,7 +1571,7 @@ function ConvertPsObjectsToMamlModel
15711571
}
15721572
}
15731573

1574-
$syntaxParam = $Help.syntax.syntaxItem.parameter | ? {$_.Name -eq $Parameter.Name} | Select -First 1
1574+
$syntaxParam = $Help.syntax.syntaxItem.parameter | Where-Object {$_.Name -eq $Parameter.Name} | Select-Object -First 1
15751575
if ($syntaxParam)
15761576
{
15771577
# otherwise we could potentialy get it from Reflection but not doing it for now
@@ -1596,7 +1596,7 @@ function ConvertPsObjectsToMamlModel
15961596
if (IsCommonParameterName $Parameter.Name -Workflow:$IsWorkflow)
15971597
{
15981598
# but don't ignore them, if they have explicit help entries
1599-
if ($Help.parameters.parameter | ? {$_.Name -eq $Parameter.Name})
1599+
if ($Help.parameters.parameter | Where-Object {$_.Name -eq $Parameter.Name})
16001600
{
16011601
}
16021602
else
@@ -1753,7 +1753,7 @@ function ConvertPsObjectsToMamlModel
17531753
#region Inputs
17541754
$Inputs = @()
17551755

1756-
$Help.inputTypes.inputType | % {
1756+
$Help.inputTypes.inputType | ForEach-Object {
17571757
$InputObject = New-Object -TypeName Markdown.MAML.Model.MAML.MamlInputOutput
17581758
$InputObject.TypeName = $_.type.name
17591759
$InputObject.Description = $_.description.Text | AddLineBreaksForParagraphs
@@ -1769,7 +1769,7 @@ function ConvertPsObjectsToMamlModel
17691769
#region Outputs
17701770
$Outputs = @()
17711771

1772-
$Help.returnValues.returnValue | % {
1772+
$Help.returnValues.returnValue | ForEach-Object {
17731773
$OutputObject = New-Object -TypeName Markdown.MAML.Model.MAML.MamlInputOutput
17741774
$OutputObject.TypeName = $_.type.name
17751775
$OutputObject.Description = $_.description.Text | AddLineBreaksForParagraphs
@@ -1790,13 +1790,13 @@ function ConvertPsObjectsToMamlModel
17901790
[string]$Name
17911791
)
17921792

1793-
$defaultSyntax = $MamlCommandObject.Syntax | ? { $Command.DefaultParameterSet -eq $_.ParameterSetName }
1793+
$defaultSyntax = $MamlCommandObject.Syntax | Where-Object { $Command.DefaultParameterSet -eq $_.ParameterSetName }
17941794
# default syntax should have a priority
17951795
$syntaxes = @($defaultSyntax) + $MamlCommandObject.Syntax
17961796

17971797
foreach ($s in $syntaxes)
17981798
{
1799-
$param = $s.Parameters | ? { $_.Name -eq $Name }
1799+
$param = $s.Parameters | Where-Object { $_.Name -eq $Name }
18001800
if ($param)
18011801
{
18021802
return $param

0 commit comments

Comments
 (0)