forked from EvotecIT/PSWriteColor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSWriteColor.psm1
34 lines (31 loc) · 1.34 KB
/
PSWriteColor.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#Get public and private function definition files.
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue -Recurse )
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue -Recurse )
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\*.dll -ErrorAction SilentlyContinue -Recurse )
#Dot source the files
Foreach ($import in @($Public + $Private)) {
Try {
. $import.fullname
} Catch {
Write-Error -Message "Failed to import function $($import.fullname): $_"
}
}
Foreach ($import in @($Assembly)) {
Try {
Add-Type -Path $import.fullname
} Catch {
Write-Error -Message "Failed to import DLL $($import.fullname): $_"
}
}
Export-ModuleMember -function 'Write-Color', 'Write-ColorDev' # -Alias 'wc'
[string] $ManifestFile = '{0}.psd1' -f (Get-Item $PSCommandPath).BaseName;
$ManifestPathAndFile = Join-Path -Path $PSScriptRoot -ChildPath $ManifestFile;
if ( Test-Path -Path $ManifestPathAndFile) {
$Manifest = (Get-Content -raw $ManifestPathAndFile) | Invoke-Expression;
foreach ( $ScriptToProcess in $Manifest.ScriptsToProcess) {
$ModuleToRemove = (Get-Item (Join-Path -Path $PSScriptRoot -ChildPath $ScriptToProcess)).BaseName;
if (Get-Module $ModuleToRemove) {
Remove-Module $ModuleToRemove;
}
}
}