$repoRoot = Split-Path -Parent $PSScriptRoot $typstPath = (Get-Command typst -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty Source) if (-not $typstPath) { $fallback = Get-ChildItem "$env:LOCALAPPDATA\Microsoft\WinGet\Packages\Typst.Typst_*" -Recurse -Filter typst.exe -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty FullName $typstPath = $fallback } if (-not $typstPath) { throw "Typst CLI hittades inte. Installera Typst och kör sedan skriptet igen." } $files = Get-ChildItem (Join-Path $repoRoot "publishing") -Recurse -Filter *.typ | Sort-Object FullName foreach ($file in $files) { $output = [System.IO.Path]::ChangeExtension($file.FullName, ".pdf") Write-Host "Compiling $($file.FullName)" & $typstPath compile --root $repoRoot $file.FullName $output if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } }