Created
June 20, 2015 03:22
-
-
Save sean-m/4d38808f4d8edee8f95a to your computer and use it in GitHub Desktop.
Pseudo anonymous functions in PowerShell for live code loading/patching.
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
$cd = $(Split-Path -parent $MyInvocation.MyCommand.Definition) | |
cd $cd | |
<# | |
Code that doesn't change goes in this file which just | |
loads functions and executes them. The function loading | |
logic could even exist in another while which is dot-included. | |
#> | |
while ($true) { | |
$funcs = gci funcs\*.ps1 | |
$test_funcs = @() | |
foreach ($f in $funcs) { | |
$func_file = $f.FullName | |
$test_funcs += . $func_file | |
} | |
$test_funcs | % { $_.Invoke("Hello world") } | |
Start-Sleep -Seconds 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment