Skip to content

Instantly share code, notes, and snippets.

@xiaoyvr
Created December 18, 2012 16:00
Show Gist options
  • Save xiaoyvr/4329251 to your computer and use it in GitHub Desktop.
Save xiaoyvr/4329251 to your computer and use it in GitHub Desktop.
function include($dep){
if(-not $__includeContainer){
$__includeContainer = New-Object "system.collections.generic.hashset[string]"
}
$folder = Split-Path $MyInvocation.ScriptName -Parent
$searchPaths = $folder, $__searchPaths
foreach($path in $searchPaths){
if(Test-Path "$path\$dep.ps1"){
$file = "$path\$dep.ps1"
break
}
}
if($file){
$file = (Resolve-Path $file).ProviderPath
if($__includeContainer.add($file)){
. $file
}
}
}
function register($path){
if(-not $__searchPaths){
$__searchPaths = New-Object "system.collections.generic.list[string]"
}
$folder = Split-Path $MyInvocation.ScriptName -Parent
$fullPath = [IO.Path]::GetFullPath("$folder\$path")
if(-not $__searchPaths.contains("$fullPath")){
$__searchPaths.add("$fullPath")
}
}
. register 'libs'
. include 'funcs'
. include 'libfuncs'
& ".\xxx.ps1"
libfuntest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment