@@ -49,6 +49,14 @@ Describe "Build-Module" {
4949 $parameters [" Target" ].Attributes.Where{$_ -is [ValidateSet ]}.ValidValues | Should - Be " Clean" , " Build" , " CleanBuild"
5050 }
5151
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+
5260 It " has an Passthru switch parameter" {
5361 $parameters.ContainsKey (" Passthru" ) | Should - Be $true
5462 $parameters [" Passthru" ].ParameterType | Should - Be ([switch ])
@@ -229,7 +237,7 @@ Describe "Build-Module" {
229237 OutputDirectory = " TestDrive:\$Version "
230238 Name = " MyModule"
231239 ModuleBase = " TestDrive:\MyModule\"
232- CopyDirectories = @ ()
240+ CopyPaths = @ ()
233241 Encoding = " UTF8"
234242 PublicFilter = " Public\*.ps1"
235243 }
@@ -344,7 +352,7 @@ Describe "Build-Module" {
344352 OutputDirectory = " TestDrive:\$Version "
345353 Name = " MyModule"
346354 ModuleBase = " TestDrive:\MyModule\"
347- CopyDirectories = @ ()
355+ CopyPaths = @ ()
348356 Encoding = " UTF8"
349357 PublicFilter = " Public\*.ps1"
350358 }
@@ -455,7 +463,7 @@ Describe "Build-Module" {
455463 OutputDirectory = " TestDrive:\$Version "
456464 Name = " MyModule"
457465 ModuleBase = " TestDrive:\MyModule\"
458- CopyDirectories = @ ()
466+ CopyPaths = @ ()
459467 Encoding = " UTF8"
460468 PublicFilter = " Public\*.ps1"
461469 }
@@ -551,4 +559,38 @@ Describe "Build-Module" {
551559 ' TestDrive:\output\MyModule.psm1' | Should - FileContentMatch ' MATCHING TEST CONTENT'
552560 }
553561 }
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+ }
554596}
0 commit comments