fix: harden mirrored downloads and first-run upgrades
This commit is contained in:
1 parent
df0a7dc37a
commit
53c5680260
10 files changed
+437
-160
No files matched your search
@@ -0,0 +1,58 @@
|
||||
# Process-local Windows tool discovery shared by startup and the frozen upgrader.
|
||||
# Keep UTF-8 BOM for Windows PowerShell 5.1.
|
||||
|
||||
function Test-CommandExists {
|
||||
param([string]$Command)
|
||||
$res = Get-Command $Command -ErrorAction SilentlyContinue
|
||||
return ($null -ne $res)
|
||||
}
|
||||
|
||||
function Update-EnvironmentPath {
|
||||
$standardDirs = @(
|
||||
"$env:LOCALAPPDATA\Microsoft\WinGet\Links",
|
||||
"$env:LOCALAPPDATA\Programs\node",
|
||||
"$env:USERPROFILE\.local\share\node",
|
||||
"$env:LOCALAPPDATA\Programs\scrcpy",
|
||||
"$env:USERPROFILE\.local\share\scrcpy",
|
||||
"$env:LOCALAPPDATA\Programs\platform-tools",
|
||||
"$env:USERPROFILE\.local\share\platform-tools",
|
||||
"$env:LOCALAPPDATA\Programs\uv",
|
||||
"$env:LOCALAPPDATA\uv",
|
||||
"$env:APPDATA\uv",
|
||||
"$env:USERPROFILE\.cargo\bin",
|
||||
"$env:USERPROFILE\.local\bin",
|
||||
"$env:USERPROFILE\scoop\shims",
|
||||
"C:\ProgramData\chocolatey\bin",
|
||||
"$env:LOCALAPPDATA\Android\Sdk\platform-tools",
|
||||
"$env:LOCALAPPDATA\Android\android-sdk\platform-tools",
|
||||
"$env:ProgramFiles\Android\platform-tools",
|
||||
"${env:ProgramFiles(x86)}\Android\android-sdk\platform-tools",
|
||||
"$env:ProgramFiles\nodejs",
|
||||
"${env:ProgramFiles(x86)}\nodejs",
|
||||
"$env:APPDATA\npm"
|
||||
)
|
||||
if ($env:CARGO_HOME) { $standardDirs = @("$env:CARGO_HOME\bin") + $standardDirs }
|
||||
if ($env:ANDROID_HOME) { $standardDirs += "$env:ANDROID_HOME\platform-tools" }
|
||||
if ($env:ANDROID_SDK_ROOT) { $standardDirs += "$env:ANDROID_SDK_ROOT\platform-tools" }
|
||||
if ($env:NVM_SYMLINK) { $standardDirs = @($env:NVM_SYMLINK) + $standardDirs }
|
||||
if ($env:NVM_HOME) { $standardDirs = @($env:NVM_HOME) + $standardDirs }
|
||||
|
||||
$regPath = [Environment]::GetEnvironmentVariable("Path", "User") + ";" + [Environment]::GetEnvironmentVariable("Path", "Machine")
|
||||
$currentPaths = ($env:PATH -split ";") + ($regPath -split ";") + $standardDirs | Where-Object { [string]::IsNullOrWhiteSpace($_) -eq $false -and (Test-Path $_) } | Select-Object -Unique
|
||||
$env:PATH = $currentPaths -join ";"
|
||||
|
||||
# Ensure user-space portable tools take absolute priority over system-level outdated versions
|
||||
$portableNode = "$env:LOCALAPPDATA\Programs\node"
|
||||
if (Test-Path "$portableNode\node.exe") {
|
||||
$env:PATH = "$portableNode;$env:PATH"
|
||||
}
|
||||
$portableScrcpy = "$env:LOCALAPPDATA\Programs\scrcpy"
|
||||
if (Test-Path "$portableScrcpy\scrcpy.exe") {
|
||||
$env:PATH = "$portableScrcpy;$env:PATH"
|
||||
}
|
||||
$portablePt = "$env:LOCALAPPDATA\Programs\platform-tools"
|
||||
if (Test-Path "$portablePt\adb.exe") {
|
||||
$env:PATH = "$portablePt;$env:PATH"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user