forked from proxb/PoshRSJob
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'refs/remotes/proxb/master'
- Loading branch information
Showing
18 changed files
with
542 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Function GetFunctionByFile { | ||
[CmdletBinding()] | ||
param ( | ||
[string[]]$FilePath | ||
) | ||
|
||
$psMajorVersion = $PSVersionTable.PSVersion.Major | ||
$functionsInFile = @() | ||
ForEach ($thisFilePath in $FilePath) { | ||
Write-Verbose "Working on file : $thisFilePath" | ||
|
||
if (-not (Test-Path $thisFilePath)) { | ||
Write-Warning "Cannot find file : $thisFilePath" | ||
continue | ||
} | ||
|
||
try { | ||
Switch ($psMajorVersion) { | ||
'2' { | ||
$scriptBlockInFile = [ScriptBlock]::Create($(Get-Content $thisFilePath) -join [Environment]::NewLine) | ||
$functionsInFile += @(FindFunction -ScriptBlock $scriptBlockInFile) | ||
} | ||
Default { | ||
$AST = [System.Management.Automation.Language.Parser]::ParseFile($thisFilePath, [ref]$null, [ref]$null) | ||
$functionsInFile += $AST.FindAll( {$args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst]} , $true) | ||
} | ||
} | ||
Write-Verbose "Functions found in file : $($functionsInFile.Name -join '; ')" | ||
} | ||
catch { | ||
Write-Warning "$thisFilePath : $($_.Exception.Message)" | ||
} | ||
} | ||
$functionsInFile | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Function GetFunctionDefinitionByFunction { | ||
[CmdletBinding()] | ||
param ( | ||
[parameter(ValueFromPipeline = $True)] | ||
$FunctionItem | ||
) | ||
|
||
if ($FunctionItem -is [PSCustomObject]) { | ||
# In case of Powershell v2 | ||
$function.Body.Trim().Trim("{}") | ||
} | ||
else { | ||
# In case of Powershell v3+ | ||
$function.Body.Extent.Text.Trim("{}") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Function GetUsingVariables { | ||
Param ([scriptblock]$ScriptBlock) | ||
$ScriptBlock.ast.FindAll({$args[0] -is [System.Management.Automation.Language.UsingExpressionAst]},$True) | ||
$ScriptBlock.ast.FindAll( {$args[0] -is [System.Management.Automation.Language.UsingExpressionAst]}, $True) | ||
} |
Oops, something went wrong.