-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.ps1
More file actions
41 lines (35 loc) · 1.63 KB
/
Copy pathinstall.ps1
File metadata and controls
41 lines (35 loc) · 1.63 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
param(
[ValidateSet("Junction", "Copy")]
[string]$Mode = "Junction",
[switch]$ReplaceExisting
)
$ErrorActionPreference = "Stop"
$RepositoryRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
$SourceSkill = Join-Path $RepositoryRoot "skill\xg-reading"
$TargetSkill = Join-Path $HOME ".codex\skills\xg-reading"
if (-not (Test-Path -LiteralPath $SourceSkill)) {
throw "Cannot find XG-Reading skill source: $SourceSkill"
}
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $TargetSkill) | Out-Null
if (Test-Path -LiteralPath $TargetSkill) {
$existing = Get-Item -LiteralPath $TargetSkill -Force
$isMatchingJunction = $existing.LinkType -eq "Junction" -and $existing.Target -contains $SourceSkill
$canReuse = $Mode -eq "Junction" -and $isMatchingJunction
if (-not $canReuse -and -not $ReplaceExisting) {
throw "Existing skill found at $TargetSkill. Re-run with -ReplaceExisting after backing up any local changes."
}
if (-not $canReuse) {
Remove-Item -LiteralPath $TargetSkill -Recurse -Force
}
}
if ($Mode -eq "Junction") {
if (-not (Test-Path -LiteralPath $TargetSkill)) {
New-Item -ItemType Junction -Path $TargetSkill -Target $SourceSkill | Out-Null
}
} else {
Copy-Item -LiteralPath $SourceSkill -Destination $TargetSkill -Recurse -Force
$LocalConfig = Join-Path $TargetSkill "xg-reading.local.json"
@{ repository_root = $RepositoryRoot } | ConvertTo-Json | Set-Content -LiteralPath $LocalConfig -Encoding utf8
}
Write-Host "XG-Reading installed from: $RepositoryRoot"
Write-Host "Paper outputs will be created in: $(Join-Path $RepositoryRoot 'outputs')"