@@ -125,6 +125,59 @@ Describe "Supports building without a build.psd1" -Tag Integration {
125
125
$Build.Metadata.FunctionsToExport | Should - Be @ (" Get-Source" , " Set-Source" )
126
126
}
127
127
}
128
+
129
+
130
+ Describe " Defaults to VersionedOutputDirectory" - Tag Integration {
131
+ Copy-Item $PSScriptRoot \Source1 TestDrive:\Source1 - Recurse
132
+ # This is the old build, with a build.psd1
133
+ $Output = Build-Module TestDrive:\Source1\build.psd1 - Passthru
134
+ $ManifestContent = Get-Content $Output.Path
135
+ $ModuleContent = Get-Content ([IO.Path ]::ChangeExtension($Output.Path , " .psm1" ))
136
+ Remove-Item (Split-Path $Output.Path ) - Recurse
137
+
138
+ # Then remove the build.psd1 and rebuild it
139
+ Remove-Item TestDrive:\Source1\build.psd1
140
+
141
+ $Build = @ { }
142
+
143
+ It " Builds into a folder with version by default" {
144
+ $BuildParameters = @ {
145
+ SourcePath = " TestDrive:\Source1\Source1.psd1"
146
+ OutputDirectory = " TestDrive:\Output1"
147
+ }
148
+
149
+ $Build.Output = Build-Module @BuildParameters - Passthru
150
+ (Convert-FolderSeparator $Build.Output.Path ) | Should - Be (Convert-FolderSeparator " TestDrive:\Output1\Source1\1.0.0\Source1.psd1" )
151
+ }
152
+
153
+ It " Builds into a folder with no version when UnversionedOutputDirectory" {
154
+ $BuildParameters = @ {
155
+ SourcePath = " TestDrive:\Source1\Source1.psd1"
156
+ OutputDirectory = " TestDrive:\Output2"
157
+ UnversionedOutputDirectory = $true
158
+ }
159
+
160
+ $Build.Output = Build-Module @BuildParameters - Passthru
161
+ (Convert-FolderSeparator $Build.Output.Path ) | Should - Be (Convert-FolderSeparator " TestDrive:\Output2\Source1\Source1.psd1" )
162
+ }
163
+
164
+ It " Creates the same module as with a build.psd1" {
165
+ $Build.Metadata = Import-Metadata $Build.Output.Path
166
+ Get-Content $Build.Output.Path | Should - Be $ManifestContent
167
+ Get-Content ([IO.Path ]::ChangeExtension($Build.Output.Path , " .psm1" )) | Should - Be $ModuleContent
168
+ }
169
+
170
+ It " Should update AliasesToExport in the manifest" {
171
+ $Build.Metadata.AliasesToExport | Should - Be @ (" GS" , " GSou" , " SS" , " SSou" )
172
+ }
173
+
174
+ It " Should update FunctionsToExport in the manifest" {
175
+ $Build.Metadata.FunctionsToExport | Should - Be @ (" Get-Source" , " Set-Source" )
176
+ }
177
+ }
178
+
179
+
180
+
128
181
Describe " Supports building discovering the module without a build.psd1" - Tag Integration {
129
182
Copy-Item $PSScriptRoot \Source1 TestDrive:\source - Recurse
130
183
@@ -212,8 +265,8 @@ if ($PSVersionTable.Platform -eq "Win32NT") {
212
265
$Result = Build-Module - SourcePath ' TestDrive:/MyModule.psd1' - Version " 1.0.0" - OutputDirectory ' ./output' - Encoding UTF8 - SourceDirectories @ (' Public' ) - Target Build - Passthru
213
266
214
267
It " Builds the Module in the designated output folder" {
215
- $Result.ModuleBase | Convert-FolderSeparator | Should - Be (Convert-FolderSeparator " TestDrive:/Output/MyModule" )
216
- ' TestDrive:/Output/MyModule/MyModule.psm1' | Convert-FolderSeparator | Should - FileContentMatch ' MATCHING TEST CONTENT'
268
+ $Result.ModuleBase | Convert-FolderSeparator | Should - Be (Convert-FolderSeparator " TestDrive:/Output/MyModule/1.0.0 " )
269
+ ' TestDrive:/Output/MyModule/1.0.0/ MyModule.psm1' | Convert-FolderSeparator | Should - FileContentMatch ' MATCHING TEST CONTENT'
217
270
}
218
271
}
219
272
}
@@ -235,13 +288,13 @@ Describe "Copies additional items specified in CopyPaths" {
235
288
$Result = Build-Module - SourcePath ' TestDrive:/build.psd1' - OutputDirectory ' ./output' - Version ' 1.0.0' - Passthru - Target Build
236
289
237
290
It " Copies single files that are in CopyPaths" {
238
- (Convert-FolderSeparator $Result.ModuleBase ) | Should - Be (Convert-FolderSeparator " $TestDrive /output/MyModule" )
239
- ' TestDrive:/output/MyModule/MyModule.format.ps1xml' | Should - Exist
240
- ' TestDrive:/output/MyModule/MyModule.format.ps1xml' | Should - FileContentMatch ' <Configuration />'
291
+ (Convert-FolderSeparator $Result.ModuleBase ) | Should - Be (Convert-FolderSeparator " $TestDrive /output/MyModule/1.0.0 " )
292
+ ' TestDrive:/output/MyModule/1.0.0/ MyModule.format.ps1xml' | Should - Exist
293
+ ' TestDrive:/output/MyModule/1.0.0/ MyModule.format.ps1xml' | Should - FileContentMatch ' <Configuration />'
241
294
}
242
295
243
296
It " Recursively copies all the files in folders that are in CopyPaths" {
244
- ' TestDrive:/output/MyModule/lib/imaginary1.dll' | Should - FileContentMatch ' 1'
245
- ' TestDrive:/output/MyModule/lib/subdir/imaginary2.dll' | Should - FileContentMatch ' 2'
297
+ ' TestDrive:/output/MyModule/1.0.0/ lib/imaginary1.dll' | Should - FileContentMatch ' 1'
298
+ ' TestDrive:/output/MyModule/1.0.0/ lib/subdir/imaginary2.dll' | Should - FileContentMatch ' 2'
246
299
}
247
300
}
0 commit comments