@@ -49,6 +49,14 @@ Describe "Build-Module" {
49
49
$parameters [" Target" ].Attributes.Where{$_ -is [ValidateSet ]}.ValidValues | Should - Be " Clean" , " Build" , " CleanBuild"
50
50
}
51
51
52
+ It " supports an optional string array parameter CopyPaths (which used to be CopyDirectories)" {
53
+ $parameters.ContainsKey (" CopyPaths" ) | Should - Be $true
54
+
55
+ # Techincally we could implement this a few other ways ...
56
+ $parameters [" CopyPaths" ].ParameterType | Should - Be ([string []])
57
+ $parameters [" CopyPaths" ].Aliases | Should - Contain " CopyDirectories"
58
+ }
59
+
52
60
It " has an Passthru switch parameter" {
53
61
$parameters.ContainsKey (" Passthru" ) | Should - Be $true
54
62
$parameters [" Passthru" ].ParameterType | Should - Be ([switch ])
@@ -229,7 +237,7 @@ Describe "Build-Module" {
229
237
OutputDirectory = " TestDrive:\$Version "
230
238
Name = " MyModule"
231
239
ModuleBase = " TestDrive:\MyModule\"
232
- CopyDirectories = @ ()
240
+ CopyPaths = @ ()
233
241
Encoding = " UTF8"
234
242
PublicFilter = " Public\*.ps1"
235
243
}
@@ -344,7 +352,7 @@ Describe "Build-Module" {
344
352
OutputDirectory = " TestDrive:\$Version "
345
353
Name = " MyModule"
346
354
ModuleBase = " TestDrive:\MyModule\"
347
- CopyDirectories = @ ()
355
+ CopyPaths = @ ()
348
356
Encoding = " UTF8"
349
357
PublicFilter = " Public\*.ps1"
350
358
}
@@ -455,7 +463,7 @@ Describe "Build-Module" {
455
463
OutputDirectory = " TestDrive:\$Version "
456
464
Name = " MyModule"
457
465
ModuleBase = " TestDrive:\MyModule\"
458
- CopyDirectories = @ ()
466
+ CopyPaths = @ ()
459
467
Encoding = " UTF8"
460
468
PublicFilter = " Public\*.ps1"
461
469
}
@@ -551,4 +559,38 @@ Describe "Build-Module" {
551
559
' TestDrive:\output\MyModule.psm1' | Should - FileContentMatch ' MATCHING TEST CONTENT'
552
560
}
553
561
}
562
+
563
+ Context " Copies additional items specified in CopyPaths" {
564
+
565
+ $null = New-Item " TestDrive:\build.psd1" - Type File - Force - Value " @{}"
566
+ $null = New-ModuleManifest " TestDrive:\MyModule.psd1" - ModuleVersion " 1.0.0" - Author " Tester"
567
+ $null = New-Item " TestDrive:\Public\Test.ps1" - Type File - Value ' MATCHING TEST CONTENT' - Force
568
+ $null = New-Item " TestDrive:\MyModule.format.ps1xml" - Type File - Value ' <Configuration />' - Force
569
+ $null = New-Item " TestDrive:\lib\imaginary1.dll" - Type File - Value ' 1' - Force
570
+ $null = New-Item " TestDrive:\lib\subdir\imaginary2.dll" - Type File - Value ' 2' - Force
571
+
572
+ Mock GetBuildInfo - ModuleName ModuleBuilder {
573
+ [PSCustomObject ]@ {
574
+ SourcePath = " TestDrive:\MyModule.psd1"
575
+ Version = [Version ]" 1.0.0"
576
+ OutputDirectory = " ./output"
577
+ CopyPaths = " ./lib" , " ./MyModule.format.ps1xml"
578
+ Encoding = ' UTF8'
579
+ SourceDirectories = @ (' Public' )
580
+ }
581
+ }
582
+
583
+ $Result = Build-Module - SourcePath ' TestDrive:\build.psd1' - OutputDirectory ' .\output' - Passthru - Target Build
584
+
585
+ It " Copies single files that are in CopyPaths" {
586
+ $Result.ModuleBase | Should - Be (" TestDrive:\output" | Convert-Path ).TrimEnd(' \' )
587
+ ' TestDrive:\output\MyModule.format.ps1xml' | Should - Exist
588
+ ' TestDrive:\output\MyModule.format.ps1xml' | Should - FileContentMatch ' <Configuration />'
589
+ }
590
+
591
+ It " Recursively copies all the files in folders that are in CopyPaths" {
592
+ ' TestDrive:\output\lib\imaginary1.dll' | Should - FileContentMatch ' 1'
593
+ ' TestDrive:\output\lib\subdir\imaginary2.dll' | Should - FileContentMatch ' 2'
594
+ }
595
+ }
554
596
}
0 commit comments