Skip to content

Commit

Permalink
fix: Import-TypeView -FilePath is optional ( Fixes #236 )
Browse files Browse the repository at this point in the history
  • Loading branch information
StartAutomating committed Jul 7, 2024
1 parent 4b42bf6 commit d3e200a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Commands/Types.PS1XML/Import-TypeView.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@
{
<#
.Synopsis
Imports a Type View
Imports Type Views
.Description
Imports a Type View, defined in a external file.
Imports one or more Type Views from a directory (and an optional list of commands).
This creates a .types.ps1xml file that can be used to extend the type system of PowerShell.
Each file in the directory will be treated as a property or method of a type.
.Link
Write-TypeView
.Example
Import-TypeView .\Types
#>
param(
# The path containing type information.
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[Parameter(ValueFromPipelineByPropertyName)]
[Alias('FullName')]
[string[]]
$FilePath,
Expand Down Expand Up @@ -58,8 +62,8 @@
$writeTypeViewSplat = @{
TypeName = if ($Namespace) { "$Namespace.Commands" } else { 'Commands' }
ScriptMethod = [Ordered]@{}
}
foreach ($cmd in $command) {
}
foreach ($cmd in $command) {
if ($cmd -is [Management.Automation.FunctionInfo]) {
$writeTypeViewSplat.ScriptMethod[$cmd.Name] = $cmd.ScriptBlock
}
Expand Down

0 comments on commit d3e200a

Please sign in to comment.