Skip to content

Commit

Permalink
Actually fixed ScriptsToProcess issue +semver: major
Browse files Browse the repository at this point in the history
  • Loading branch information
codaamok committed Mar 2, 2022
1 parent 41a1a8f commit 57f126d
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 8 additions & 2 deletions invoke.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 8 additions & 2 deletions src/Files/invoke.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
14 changes: 8 additions & 6 deletions src/Public/Build/Export-ScriptsToProcess.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down

0 comments on commit 57f126d

Please sign in to comment.