fix(windows): handle null Path when running install.ps1 via irm | iex

When running via 'irm ccs.kaitran.ca/install.ps1 | iex', the script executes
in-memory without a file path, causing $MyInvocation.MyCommand.Path to be null.
This fix checks for null before calling Split-Path to avoid the error:
'Cannot bind argument to parameter Path because it is null'

Resolves standalone installation method detection for piped execution.
This commit is contained in:
kaitranntt
2025-11-02 02:25:19 -05:00
parent a4245e9031
commit 411d3850a2
+12 -2
View File
@@ -13,8 +13,18 @@ $ClaudeDir = "$env:USERPROFILE\.claude"
$GlmModel = "glm-4.6"
# Detect if running from git repository or standalone
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$InstallMethod = if (Test-Path "$ScriptDir\ccs.ps1") { "git" } else { "standalone" }
$ScriptDir = if ($MyInvocation.MyCommand.Path) {
Split-Path -Parent $MyInvocation.MyCommand.Path
} else {
# Running via irm | iex (in-memory, no file path)
$null
}
$InstallMethod = if ($ScriptDir -and (Test-Path "$ScriptDir\ccs.ps1")) {
"git"
} else {
"standalone"
}
# Helper Functions