diff --git a/CHANGELOG.md b/CHANGELOG.md index ef08be0..0217b76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,13 @@ ## [Unreleased] +### Added +- New mandatory parameter `-File` for `Export-ScriptsToProcess`; must provide a scalar or array object of `[System.IO.FileSystemInfo]` as the file(s) you want concatenated into a single file. + +### Fixed +- Actually fixed the `Process.ps1` ScriptsToProcess issue, by fixing incorrect script scope variable reference in `Export-ScriptsToProcess` ## [3.1.2] - 2022-03-02 ### Fixed -- Build script did not creat the `Process.ps1` script file (for ScriptsToProcess) even if scripts existed under `src\ScriptsToProcess` +- Build script did not create the `Process.ps1` script file (for ScriptsToProcess) even if scripts existed under `src\ScriptsToProcess` ## [3.1.1] - 2022-03-01 ### Added diff --git a/invoke.build.ps1 b/invoke.build.ps1 index 3313b85..6f19688 100644 --- a/invoke.build.ps1 +++ b/invoke.build.ps1 @@ -116,8 +116,14 @@ task CreateRootModule { } # Synopsis: Create a single Process.ps1 script file for all script files under ScriptsToProcess\* (if any) -task CreateProcessScript -If (Test-Path -Path ("{0}\src\ScriptsToProcess\*" -f $BuildRoot) -Include "*.ps1") { - Export-ScriptsToProcess -Path ("{0}\src\ScriptsToProcess" -f $BuildRoot) +$Params = @{ + Path = "{0}\src\ScriptsToProcess\*" -f $BuildRoot + Include = "*.ps1" +} + +task CreateProcessScript -If (Test-Path @Params) { + $Path = "{0}\build\{1}\Process.ps1" -f $BuildRoot, $Script:ModuleName + Export-ScriptsToProcess -File (Get-ChildItem @Params) -Path $Path $Script:ProcessScript = $true } diff --git a/src/Files/invoke.build.ps1 b/src/Files/invoke.build.ps1 index 3313b85..6f19688 100644 --- a/src/Files/invoke.build.ps1 +++ b/src/Files/invoke.build.ps1 @@ -116,8 +116,14 @@ task CreateRootModule { } # Synopsis: Create a single Process.ps1 script file for all script files under ScriptsToProcess\* (if any) -task CreateProcessScript -If (Test-Path -Path ("{0}\src\ScriptsToProcess\*" -f $BuildRoot) -Include "*.ps1") { - Export-ScriptsToProcess -Path ("{0}\src\ScriptsToProcess" -f $BuildRoot) +$Params = @{ + Path = "{0}\src\ScriptsToProcess\*" -f $BuildRoot + Include = "*.ps1" +} + +task CreateProcessScript -If (Test-Path @Params) { + $Path = "{0}\build\{1}\Process.ps1" -f $BuildRoot, $Script:ModuleName + Export-ScriptsToProcess -File (Get-ChildItem @Params) -Path $Path $Script:ProcessScript = $true } diff --git a/src/Public/Build/Export-ScriptsToProcess.ps1 b/src/Public/Build/Export-ScriptsToProcess.ps1 index e34dfe5..923f91f 100644 --- a/src/Public/Build/Export-ScriptsToProcess.ps1 +++ b/src/Public/Build/Export-ScriptsToProcess.ps1 @@ -12,17 +12,19 @@ function Export-ScriptsToProcess { [CmdletBinding()] param ( [Parameter(Mandatory)] - [String[]]$Path + [System.IO.FileSystemInfo[]]$File, + + [Parameter(Mandatory)] + [String]$Path ) - $ProcessScript = New-Item -Path $BuildRoot\build\$Script:ModuleName\Process.ps1 -ItemType "File" -Force - $Files = @(Get-ChildItem $Path -Filter *.ps1) + $ProcessScript = New-Item -Path $Path -ItemType "File" -Force - foreach ($File in $Files) { - Get-Content -Path $File.FullName | Add-Content -Path $ProcessScript + foreach ($_File in $File) { + Get-Content -Path $_File.FullName | Add-Content -Path $ProcessScript # Add new line only if the current file isn't the last one (minus 1 because array indexes from 0) - if ($Files.IndexOf($File) -ne ($Files.Count - 1)) { + if ($File.IndexOf($_File) -ne ($File.Count - 1)) { Write-Output "" | Add-Content -Path $ProcessScript } }