Skip to content

Commit

Permalink
v2.1.2: Fixed #11 and #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephanevg committed Oct 5, 2018
1 parent ba9985d commit 458af9e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
15 changes: 10 additions & 5 deletions Functions/Private/Get-CUAST.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Function Get-CUAst {
------- ----- ------
{mystarshIp, Cruiser, Dreadnought} {ShipClass, ShipSpeed, Cloak} JeffHicks_StarShipModule.ps1
.NOTES:
.LINK
https://github.com/Stephanevg/PSClassUtils/
#>
[CmdletBinding()]
Expand All @@ -65,7 +69,7 @@ Function Get-CUAst {
ValueFromPipeline = $true
)]
[Alias('FullName')]
[System.IO.FileInfo[]]$Path
[String[]]$Path
)

begin {
Expand Down Expand Up @@ -96,11 +100,11 @@ Function Get-CUAst {
if($Path){
foreach($p in $Path){

[System.IO.FileInfo]$File = (Resolve-Path -Path $p.FullName).Path
Write-Verbose "AST: $($p.FullName)"
$AST = [System.Management.Automation.Language.Parser]::ParseFile($p.FullName, [ref]$null, [ref]$Null)
[System.IO.FileInfo]$File = (Resolve-Path -Path $p).Path
Write-Verbose "AST: $($File.FullName)"
$AST = [System.Management.Automation.Language.Parser]::ParseFile($File.FullName, [ref]$null, [ref]$Null)

sortast -RawAST $AST -Source $File.Name
sortast -RawAST $AST -Source $File.FullName
}
}else{

Expand All @@ -117,3 +121,4 @@ Function Get-CUAst {
end {
}
}

3 changes: 2 additions & 1 deletion Functions/Public/Write-CUClassDiagram.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Function Write-CUClassDiagram {
$AllItems = $Path
}ElseIf($FolderPath){

$AllItems = Get-ChildItem -path $FolderPath.FullName -Recurse
$AllItems = Get-ChildItem -path "$($FolderPath.FullName)\*" -Include "*.ps1", "*.psm1" -Recurse

}

Expand Down Expand Up @@ -188,3 +188,4 @@ Function Write-CUClassDiagram {

}

#Write-CUClassDiagram -Path .\Class.HostsManagement.psm1
2 changes: 1 addition & 1 deletion PSClassUtils.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSClassUtils.psm1'

# Version number of this module.
ModuleVersion = '2.1.1'
ModuleVersion = '2.1.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
15 changes: 15 additions & 0 deletions Tests/ClassUtils.Class-Get-CUAST.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,20 @@ InModuleScope PSClassUtils -ScriptBlock {
It 'Parameter: -InputObject Should work as parameter'{
($ClassScript | Get-CUAST).GetType().FullName | should be "ASTDocument"
}

It '[BugFix] RelativePath: Should resolve Relative Path without throwing'{
Push-Location
set-location $Testdrive
{Get-CUAst -Path ".\WoopClass.ps1"} | should not throw
Pop-Location
}

It '[BugFix] RelativePath: Should point to correct file path'{
Push-Location
set-location $Testdrive
$obj = Get-CUAst -Path ".\WoopClass.ps1"
$obj.Source | should be $ClassScript
Pop-Location
}
}
}

0 comments on commit 458af9e

Please sign in to comment.