@@ -21,6 +21,9 @@ The description of the module.
21
21
. PARAMETER Tags
22
22
The tags for the module.
23
23
24
+ . PARAMETER LicenseUri
25
+ The URL for the repo's license.
26
+
24
27
. PARAMETER SourceDirectory
25
28
The source directory of the module. Should be a nested directory that doesn't contain and build scripts.
26
29
@@ -50,6 +53,7 @@ function Build-PSModule {
50
53
[String ]$Version = ' 0.0.1' ,
51
54
[String ]$Description = ' A PowerShell module.' ,
52
55
[String []]$Tags = @ (' PSEdition_Desktop' , ' PSEdition_Core' , ' Windows' ),
56
+ [String ]$LicenseUri = ' https://opensource.org/licenses/MIT' ,
53
57
[String ]$SourceDirectory = " $PWD /src" ,
54
58
[String ]$OutputDirectory = " $PWD /out" ,
55
59
[Switch ]$FixScriptAnalyzer
@@ -62,6 +66,7 @@ function Build-PSModule {
62
66
Version = $Version
63
67
Description = $Description
64
68
Tags = $Tags
69
+ LicenseUri = $LicenseUri
65
70
SourceDirectory = $SourceDirectory
66
71
OutputDirectory = $OutputDirectory
67
72
FixScriptAnalyzer = $FixScriptAnalyzer
@@ -102,6 +107,15 @@ function Build-PSModule {
102
107
$moduleContent += $functionContent
103
108
}
104
109
110
+ $srcModuleContent = Get-Content - Path " $SourceDirectory \$Name .psm1" - Raw
111
+ $startIndex = $srcModuleContent.IndexOf (' Get-ChildItem' )
112
+ $subString = $srcModuleContent.Substring ($startIndex )
113
+ $braceIndex = $subString.IndexOf (' }' )
114
+ $moduleScriptContent = $subString.Substring ($braceIndex + 1 )
115
+ if ($moduleScriptContent ) {
116
+ $moduleContent += $moduleScriptContent
117
+ }
118
+
105
119
$moduleContent | Set-Content - Path " $ModuleOutputDirectory /$name .psm1" - Force
106
120
$null = New-Item - Path " $ModuleOutputDirectory /private" - ItemType Directory - Force
107
121
Get-ChildItem - Path " $SourceDirectory /private" - Exclude ' *.Tests.ps1' |
@@ -124,7 +138,7 @@ function Build-PSModule {
124
138
else {
125
139
( New-Guid ).Guid
126
140
}
127
- $requiredModulesStatement = Get-Content - Path " $SourceDirectory \ $Name .psm1 " |
141
+ $requiredModulesStatement = $srcModuleContent .Split ( " `n " ) |
128
142
Where-Object - FilterScript { $_ -match ' #Requires' }
129
143
$requiredModules = (($requiredModulesStatement -split ' -Modules ' )[1 ] -split ' ,' ).Trim() |
130
144
ForEach-Object {
@@ -137,21 +151,21 @@ function Build-PSModule {
137
151
}
138
152
$moduleVersion , $modulePrerelease = $Version -split ' -' , 2
139
153
$newModuleManifest = @ {
140
- Path = $manifestPath
141
- Author = (( & git log -- format= ' %aN' -- . | Sort-Object - Unique ) -join ' , ' )
142
- CompanyName = $companyName
143
- Copyright = " (c) $ ( Get-Date - Format yyyy ) $companyName . All rights reserved."
144
- RootModule = " $Name .psm1"
145
- ModuleVersion = $moduleVersion
146
- Guid = $guid
147
- Description = $Description
148
- PowerShellVersion = 5.1
149
- FunctionsToExport = $functionNames
154
+ Path = $manifestPath
155
+ Author = (( & git log -- format= ' %aN' -- . | Sort-Object - Unique ) -join ' , ' )
156
+ CompanyName = $companyName
157
+ Copyright = " (c) $ ( Get-Date - Format yyyy ) $companyName . All rights reserved."
158
+ RootModule = " $Name .psm1"
159
+ ModuleVersion = $moduleVersion
160
+ Guid = $guid
161
+ Description = $Description
162
+ PowerShellVersion = 5.1
163
+ FunctionsToExport = $functionNames
150
164
CompatiblePSEditions = (' Desktop' , ' Core' )
151
- Tags = $Tags
152
- ProjectUri = $repoUrl
153
- LicenseUri = ' https://opensource.org/licenses/MIT '
154
- ReleaseNotes = ( git log -1 -- pretty=% B )[0 ]
165
+ Tags = $Tags
166
+ ProjectUri = $repoUrl
167
+ LicenseUri = $LicenseUri
168
+ ReleaseNotes = ( git log -1 -- pretty=% B )[0 ]
155
169
}
156
170
if ($requiredModules ) {
157
171
$newModuleManifest [' RequiredModules' ] = $requiredModules
0 commit comments