@@ -18,33 +18,33 @@ $importIndividualFiles = Get-PSFConfigValue -FullName Hawk.Import.IndividualFile
18
18
if ($Hawk_importIndividualFiles ) { $importIndividualFiles = $true }
19
19
if (Test-Path (Resolve-PSFPath - Path " $ ( $script :ModuleRoot ) \..\.git" - SingleItem - NewChild)) { $importIndividualFiles = $true }
20
20
if (" <was not compiled>" -eq ' <was not compiled>' ) { $importIndividualFiles = $true }
21
-
21
+
22
22
function Import-ModuleFile
23
23
{
24
24
<#
25
25
. SYNOPSIS
26
26
Loads files into the module on module import.
27
-
27
+
28
28
. DESCRIPTION
29
29
This helper function is used during module initialization.
30
30
It should always be dotsourced itself, in order to proper function.
31
-
31
+
32
32
This provides a central location to react to files being imported, if later desired
33
-
33
+
34
34
. PARAMETER Path
35
35
The path to the file to load
36
-
36
+
37
37
. EXAMPLE
38
38
PS C:\> . Import-ModuleFile -File $function.FullName
39
-
39
+
40
40
Imports the file stored in $function according to import policy
41
41
#>
42
42
[CmdletBinding ()]
43
43
Param (
44
44
[string ]
45
45
$Path
46
46
)
47
-
47
+
48
48
$resolvedPath = $ExecutionContext.SessionState.Path.GetResolvedPSPathFromPSPath ($Path ).ProviderPath
49
49
if ($doDotSource ) { . $resolvedPath }
50
50
else { $ExecutionContext.InvokeCommand.InvokeScript ($false , ([scriptblock ]::Create([io.file ]::ReadAllText($resolvedPath ))), $null , $null ) }
@@ -57,24 +57,24 @@ if ($importIndividualFiles)
57
57
foreach ($path in (& " $ModuleRoot \internal\scripts\preimport.ps1" )) {
58
58
. Import-ModuleFile - Path $path
59
59
}
60
-
60
+
61
61
# Import all internal functions
62
62
foreach ($function in (Get-ChildItem " $ModuleRoot \internal\functions" - Filter " *.ps1" - Recurse - ErrorAction Ignore))
63
63
{
64
64
. Import-ModuleFile - Path $function.FullName
65
65
}
66
-
66
+
67
67
# Import all public functions
68
68
foreach ($function in (Get-ChildItem " $ModuleRoot \functions" - Filter " *.ps1" - Recurse - ErrorAction Ignore))
69
69
{
70
70
. Import-ModuleFile - Path $function.FullName
71
71
}
72
-
72
+
73
73
# Execute Postimport actions
74
74
foreach ($path in (& " $ModuleRoot \internal\scripts\postimport.ps1" )) {
75
75
. Import-ModuleFile - Path $path
76
76
}
77
-
77
+
78
78
# End it here, do not load compiled code below
79
79
return
80
80
}
0 commit comments