Better....
Better Edit-DokcerCompose (suppress errors when permissions don't allow) Better aliases (eds and edc) Better Git commands.
This commit is contained in:
parent
86fdee1acc
commit
33b4c5166b
7 changed files with 59 additions and 7 deletions
32
base/Get-ScriptFunction.ps1
Normal file
32
base/Get-ScriptFunction.ps1
Normal file
|
@ -0,0 +1,32 @@
|
|||
[CmdletBinding()]param(
|
||||
[string[]]$Path
|
||||
# Path to script
|
||||
)
|
||||
BEGIN{}
|
||||
PROCESS{
|
||||
foreach( $local:scriptPath in $Path ) {
|
||||
$rs = [runspacefactory]::CreateRunspace()
|
||||
$rs.Open()
|
||||
|
||||
# Get the AST of the file
|
||||
$tokens = $errors = $null
|
||||
$ast = [System.Management.Automation.Language.Parser]::ParseFile(
|
||||
$scriptPath,
|
||||
[ref]$tokens,
|
||||
[ref]$errors)
|
||||
|
||||
# Get only function definition ASTs
|
||||
$functionDefinitions = $ast.FindAll({
|
||||
param([System.Management.Automation.Language.Ast] $Ast)
|
||||
|
||||
$Ast -is [System.Management.Automation.Language.FunctionDefinitionAst] -and
|
||||
# Class methods have a FunctionDefinitionAst under them as well, but we don't want them.
|
||||
($PSVersionTable.PSVersion.Major -lt 5 -or
|
||||
$Ast.Parent -isnot [System.Management.Automation.Language.FunctionMemberAst])
|
||||
|
||||
}, $true)
|
||||
|
||||
$functionDefinitions
|
||||
}
|
||||
}
|
||||
END{}
|
Loading…
Add table
Add a link
Reference in a new issue