Reputation: 3033
Is it possible to reference in Powershell all the scripts contained in some folder? Something like:
."$PSScriptRoot\helpers\*.ps1"
I'm building types dynamically using:
New-Object -TypeName "$($fixture)Runner";
and I really want to reinforce convention over configuration, by setting all the types under that "helpers" folder.
Is that possible?
If I use the asterisk as a kind of regex then Powershell is not able to find the types I'm trying to instantiate.
Upvotes: 1
Views: 51
Reputation: 37740
To reference the code in the files you can "Dot Source" them:
Get-ChildItem "$PSScriptRoot\helpers\*.ps1" | ForEach-Object{. $_.FullName}
Upvotes: 2