Prepare wordcraft-mcp and gridcraft-mcp 0.2.0: ASCII display_name, ArtCraft docs, UTF-8 fixes.
This commit is contained in:
1 parent
73a6d3e9d0
commit
debdf92877
15 files changed
+130
-67
No files matched your search
+25
-3
@@ -5,16 +5,38 @@ $ErrorActionPreference = 'Stop'
|
||||
$Root = Split-Path -Parent $PSScriptRoot
|
||||
$SkillsDir = Join-Path $Root 'skills'
|
||||
$DistDir = Join-Path $Root 'dist'
|
||||
$Utf8NoBom = New-Object System.Text.UTF8Encoding $false
|
||||
$Utf8NoBom = [System.Text.UTF8Encoding]::new($false)
|
||||
|
||||
# Datei als UTF-8 lesen, Zeilenenden auf LF vereinheitlichen.
|
||||
function Read-Text([string]$Path) {
|
||||
return ([IO.File]::ReadAllText($Path, [Text.Encoding]::UTF8) -replace "`r", '')
|
||||
return ([System.IO.File]::ReadAllText($Path, [System.Text.Encoding]::UTF8) -replace "`r", '')
|
||||
}
|
||||
|
||||
# Datei als UTF-8 ohne BOM mit LF schreiben (Set-Content wuerde in 5.1 ein BOM schreiben).
|
||||
function Write-Text([string]$Path, [string]$Text) {
|
||||
[IO.File]::WriteAllText($Path, $Text, $Utf8NoBom)
|
||||
[System.IO.File]::WriteAllText($Path, $Text, $Utf8NoBom)
|
||||
}
|
||||
|
||||
# Prozess starten und stdout+stderr als UTF-8 ohne BOM lesen (kein Out-String / Default-Encoding).
|
||||
# $Arguments ist die Argumentzeile (PS 5.1 hat kein ProcessStartInfo.ArgumentList).
|
||||
function Get-ProcessOutputUtf8([string]$FileName, [string]$Arguments) {
|
||||
$psi = New-Object System.Diagnostics.ProcessStartInfo
|
||||
$psi.FileName = $FileName
|
||||
$psi.Arguments = $Arguments
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.RedirectStandardOutput = $true
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.CreateNoWindow = $true
|
||||
$psi.StandardOutputEncoding = $Utf8NoBom
|
||||
$psi.StandardErrorEncoding = $Utf8NoBom
|
||||
$p = [System.Diagnostics.Process]::Start($psi)
|
||||
$stdout = $p.StandardOutput.ReadToEnd()
|
||||
$stderr = $p.StandardError.ReadToEnd()
|
||||
$p.WaitForExit()
|
||||
return @{
|
||||
ExitCode = $p.ExitCode
|
||||
Output = ($stdout + $stderr)
|
||||
}
|
||||
}
|
||||
|
||||
function Test-Bom([string]$Path) {
|
||||
|
||||
Reference in new issue
Block a user