Compile-Woodpecker.ps1
|
#!/usr/bin/env pwsh [CmdletBinding()] param( [string] $RepoRoot, [string] $SourceDir, [string] $OutDir, [switch] $DryRun ) Set-StrictMode -Version Latest $ErrorActionPreference = 'Stop' Import-Module (Join-Path $PSScriptRoot 'WoodpeckerTools.psd1') ` -Force -DisableNameChecking -ErrorAction Stop if ([string]::IsNullOrWhiteSpace($RepoRoot)) { $startPath = if ([string]::IsNullOrWhiteSpace($SourceDir)) { (Get-Location).Path } else { [IO.Path]::GetFullPath($SourceDir) } $gitRoot = & git -C $startPath rev-parse --show-toplevel 2>$null if ($LASTEXITCODE -ne 0 -or [string]::IsNullOrWhiteSpace($gitRoot)) { throw 'Could not determine the repository root. Pass -RepoRoot explicitly.' } $RepoRoot = $gitRoot.Trim() } $compilerParams = @{ RepoRoot = $RepoRoot DryRun = $DryRun } if (-not [string]::IsNullOrWhiteSpace($SourceDir)) { $compilerParams.SourceDir = $SourceDir } if (-not [string]::IsNullOrWhiteSpace($OutDir)) { $compilerParams.OutDir = $OutDir } $result = Invoke-WoodpeckerPipelineCompiler @compilerParams if ($DryRun -and -not $result.InSync) { exit 1 } |