-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathHelpOut.psm1
More file actions
46 lines (39 loc) · 1.34 KB
/
HelpOut.psm1
File metadata and controls
46 lines (39 loc) · 1.34 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
$options = @{}
$myModule = $MyInvocation.MyCommand.ScriptBlock.Module
foreach ($a in $args) {
if ($a -is [string]) {
foreach ($o in $a -split '[ ,]' -ne '') {
$Options["$o".Trim()] = $true
};
continue
}
if ($a -is [Hashtable]) {foreach ($o in $a.Keys) {$options[$o] = $a[$o]};continue}
throw 'Arguments must strings or hashtables'
}
if (-not $args -and (Test-Path (Join-Path $PSScriptRoot '.git'))) {
$options["Development"] = $true
}
$validKeys = 'Development', 'Production'
foreach ($k in $options.Keys) {
if ($validKeys -notcontains $k) {
throw "Invalid option: $k"
}
}
if ($options.Development) {
foreach ($file in Get-Childitem -LiteralPath $PSScriptRoot -Filter '*-*.ps1' -Recurse) {
. $file.FullName
}
}
if ($options.Production -or -not $options.Development) {
. $PSScriptRoot\allcommands.ps1
}
$ExecutionContext.SessionState.PSVariable.Set($myModule.Name, $myModule)
$myModule.pstypeNames.Insert(0, $myModule.Name)
Export-ModuleMember -Function * -Variable $myModule.Name -Alias *
try {
$newDriveSplat = @{Name = $myModule.Name;Scope = 'Global';PSProvider='FileSystem';ErrorAction='Ignore'}
$newDriveSplat.Root = $myModule | Split-Path
New-PSDrive @newDriveSplat
} catch {
Write-Verbose "$_"
}