Files

29 lines
1.6 KiB
PowerShell

[CmdletBinding()]
param()
$ErrorActionPreference = "Stop"
$source = Join-Path $env:APPDATA "Zed"
$target = $PSScriptRoot
$utf8 = New-Object System.Text.UTF8Encoding($false)
Copy-Item -LiteralPath (Join-Path $source "settings.json") -Destination (Join-Path $target "settings.json") -Force
Copy-Item -LiteralPath (Join-Path $source "keymap.json") -Destination (Join-Path $target "keymap.json") -Force
Copy-Item -LiteralPath (Join-Path $source "scripts\toggle-file-scan-exclusions.mjs") -Destination (Join-Path $target "scripts\toggle-file-scan-exclusions.mjs") -Force
Copy-Item -LiteralPath (Join-Path $source "scripts\file-exclusions.json") -Destination (Join-Path $target "scripts\file-exclusions.json") -Force
Copy-Item -LiteralPath (Join-Path $source "scripts\zed-settings-sync.mjs") -Destination (Join-Path $target "scripts\zed-settings-sync.mjs") -Force
$tasks = [IO.File]::ReadAllText((Join-Path $source "tasks.json"))
foreach ($script in @(
@{ Path = (Join-Path $source "scripts\toggle-file-scan-exclusions.mjs"); Placeholder = "__TOGGLE_SCRIPT__" },
@{ Path = (Join-Path $source "scripts\zed-settings-sync.mjs"); Placeholder = "__SYNC_SCRIPT__" }
)) {
$tasks = $tasks.Replace($script.Path.Replace("\", "\\"), $script.Placeholder)
$tasks = $tasks.Replace($script.Path.Replace("\", "/"), $script.Placeholder)
}
[IO.File]::WriteAllText((Join-Path $target "tasks.json"), $tasks, $utf8)
node (Join-Path $source "scripts\zed-settings-sync.mjs") export (Join-Path $target "zed-settings-sync.json")
if ($LASTEXITCODE -ne 0) { throw "Failed to generate zed-settings-sync.json" }
Write-Host "Exported Zed configuration from $source"