-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSplit-SampleAnsi.ps1
More file actions
48 lines (38 loc) · 1.55 KB
/
Copy pathSplit-SampleAnsi.ps1
File metadata and controls
48 lines (38 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
[CmdletBinding()]
param(
[Parameter()]
[string]$AnsiPath = './assets/ansi-files/we-ACiDTrip.ANS',
[Parameter()]
[int]$Every = 160,
[Parameter()]
[string]$OutputDirectory = './dist/examples/we-ACiDTrip'
)
$scriptRoot = Split-Path -Path $MyInvocation.MyCommand.Path -Parent
$repoRoot = [System.IO.Path]::GetFullPath((Join-Path -Path $scriptRoot -ChildPath '..'))
$repoRoot = [System.IO.Path]::GetFullPath((Join-Path -Path $repoRoot -ChildPath '..'))
$ansiFull = Resolve-Path -LiteralPath (Join-Path -Path $repoRoot -ChildPath $AnsiPath)
$splitter = Join-Path -Path $repoRoot -ChildPath 'scripts/Split-AnsiFile.js'
if (-not (Test-Path -LiteralPath $splitter)) {
throw "Splitter not found at '$splitter'."
}
$node = Get-Command node -ErrorAction SilentlyContinue
if (-not $node) {
throw 'Node.js is required to run Split-AnsiFile.js. Install Node 18+ and re-run this script.'
}
$outDir = Join-Path -Path $repoRoot -ChildPath $OutputDirectory
if (-not (Test-Path -LiteralPath $outDir)) {
New-Item -ItemType Directory -Path $outDir -Force | Out-Null
}
Write-Host "Splitting $ansiFull into $outDir (every $Every rows, auto break detection enabled)" -ForegroundColor Cyan
$arguments = @(
$ansiFull,
'--every', $Every,
'--auto',
'--output', $outDir
)
& $node.Source $splitter @arguments
if ($LASTEXITCODE -ne 0) {
throw "Split failed with exit code $LASTEXITCODE."
}
Write-Host "✓ Slices written to $outDir" -ForegroundColor Green
Write-Host 'Convert each slice with Convert-AnsiToColorScript.js or the companion sample script.'