assemble.ps1: marqueurs tolerants LF/CRLF (autocrlf) + remplacement via MatchEvaluator (contenu JS avec \$ intact)

This commit is contained in:
nathaninline committed 2026-07-22 10:23:52 +02:00
1 parent 0770723ef0
commit 8a2450dff6
1 file changed
+5 -2
+5 -2
View File
@@ -18,10 +18,13 @@ $css = [IO.File]::ReadAllText((Join-Path $src 'styles.css'))
$js = (Get-ChildItem (Join-Path $src 'js') -Filter '*.js' | Sort-Object Name |
ForEach-Object { [IO.File]::ReadAllText($_.FullName) }) -join ''
# le marqueur et SA fin de ligne sont remplacés (LF ou CRLF selon le checkout) ;
# chaque source apporte ses propres fins de ligne → sortie byte-stable.
foreach ($m in '@@CSS@@', '@@JS@@') {
if (-not $tmpl.Contains("$m`n")) { throw "marqueur $m introuvable dans index.tmpl.html" }
if ($tmpl -notmatch "$m`r?`n") { throw "marqueur $m introuvable dans index.tmpl.html" }
}
$html = $tmpl.Replace("@@CSS@@`n", $css).Replace("@@JS@@`n", $js)
$html = [regex]::Replace($tmpl, "@@CSS@@`r?`n", { $css })
$html = [regex]::Replace($html, "@@JS@@`r?`n", { $js })
[IO.File]::WriteAllText($dst, $html, [Text.UTF8Encoding]::new($false))
Write-Host "OK -> $dst ($([IO.File]::ReadAllBytes($dst).Length) octets)"