mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 12:29:07 +00:00
* awa
* update v5
* a
* [autofix.ci] apply automated fixes
* tarball
* a
* a
* blah
* [autofix.ci] apply automated fixes
* bump
* wah
* [autofix.ci] apply automated fixes
* farther
* a
* [autofix.ci] apply automated fixes
* im confused
* [autofix.ci] apply automated fixes
* Fix typo (#9623)
* Fix crash in Bun.escapeHTML (#9619)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Fixes #9610
* Implement `fs.openAsBlob` (#9628)
* Implement `fs.openAsBlob`
* Use a function
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* Fix `bun install -g` not working on Docker
Closes #8753
* Revert "Fix `bun install -g` not working on Docker"
This reverts commit 20fce1a1be.
* what happens if nonblocking tty (#9608)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
* merge
* a
* blah
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
Co-authored-by: sequencerr <45060278+sequencerr@users.noreply.github.com>
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Co-authored-by: Ashcon Partovi <ashcon@partovi.net>
116 lines
3.5 KiB
PowerShell
116 lines
3.5 KiB
PowerShell
# This script will remove the Bun installation at the location of this
|
|
# script, removing it from %PATH%, deleting caches, and removing it from
|
|
# the list of installed programs.
|
|
param(
|
|
[switch]$PauseOnError = $false
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
# These two environment functions are roughly copied from https://github.com/prefix-dev/pixi/pull/692
|
|
# They are used instead of `SetEnvironmentVariable` because of unwanted variable expansions.
|
|
function Write-Env {
|
|
param([String]$Key, [String]$Value)
|
|
|
|
$RegisterKey = Get-Item -Path 'HKCU:'
|
|
$EnvRegisterKey = $RegisterKey.OpenSubKey('Environment', $true)
|
|
if ($null -eq $Value) {
|
|
$EnvRegisterKey.DeleteValue($Key)
|
|
} else {
|
|
$RegistryValueKind = if ($Value.Contains('%')) {
|
|
[Microsoft.Win32.RegistryValueKind]::ExpandString
|
|
} elseif ($EnvRegisterKey.GetValue($Key)) {
|
|
$EnvRegisterKey.GetValueKind($Key)
|
|
} else {
|
|
[Microsoft.Win32.RegistryValueKind]::String
|
|
}
|
|
$EnvRegisterKey.SetValue($Key, $Value, $RegistryValueKind)
|
|
}
|
|
}
|
|
|
|
function Get-Env {
|
|
param([String] $Key)
|
|
|
|
$RegisterKey = Get-Item -Path 'HKCU:'
|
|
$EnvRegisterKey = $RegisterKey.OpenSubKey('Environment')
|
|
$EnvRegisterKey.GetValue($Key, $null, [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
|
|
}
|
|
|
|
if (-not (Test-Path "${PSScriptRoot}\bin\bun.exe")) {
|
|
Write-Host "bun.exe not found in ${PSScriptRoot}\bin`n`nRefusing to delete this directory as it may.`n`nIf this uninstallation is still intentional, please just manually delete this folder."
|
|
if ($PauseOnError) { pause }
|
|
exit 1
|
|
}
|
|
|
|
function Stop-Bun {
|
|
try {
|
|
Get-Process -Name bun | Where-Object { $_.Path -eq "${PSScriptRoot}\bin\bun.exe" } | Stop-Process -Force
|
|
} catch [Microsoft.PowerShell.Commands.ProcessCommandException] {
|
|
# ignore
|
|
} catch {
|
|
Write-Host "There are open instances of bun.exe that could not be automatically closed."
|
|
if ($PauseOnError) { pause }
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
# Remove ~\.bun\bin\bun.exe
|
|
try {
|
|
Stop-Bun
|
|
Remove-Item "${PSScriptRoot}\bin\bun.exe" -Force
|
|
} catch {
|
|
# Try a second time
|
|
Stop-Bun
|
|
Start-Sleep -Seconds 1
|
|
try {
|
|
Remove-Item "${PSScriptRoot}\bin\bun.exe" -Force
|
|
} catch {
|
|
Write-Host $_
|
|
Write-Host "`n`nCould not delete ${PSScriptRoot}\bin\bun.exe."
|
|
Write-Host "Please close all instances of bun.exe and try again."
|
|
if ($PauseOnError) { pause }
|
|
exit 1
|
|
}
|
|
}
|
|
|
|
# Remove ~\.bun
|
|
try {
|
|
Remove-Item "${PSScriptRoot}" -Recurse -Force
|
|
} catch {
|
|
Write-Host "Could not delete ${PSScriptRoot}."
|
|
if ($PauseOnError) { pause }
|
|
exit 1
|
|
}
|
|
|
|
# Delete some tempdir files. Do not fail if an error happens here
|
|
try {
|
|
Remove-Item "${Temp}\bun-*" -Recurse -Force
|
|
} catch {}
|
|
try {
|
|
Remove-Item "${Temp}\bunx-*" -Recurse -Force
|
|
} catch {}
|
|
|
|
# Remove Entry from path
|
|
try {
|
|
$Path = Get-Env -Key 'Path'
|
|
$Path = $Path -split ';'
|
|
$Path = $Path | Where-Object { $_ -ne "${PSScriptRoot}\bin" }
|
|
Write-Env -Key 'Path' -Value ($Path -join ';')
|
|
} catch {
|
|
Write-Host "Could not remove ${PSScriptRoot}\bin from PATH."
|
|
Write-Error $_
|
|
if ($PauseOnError) { pause }
|
|
exit 1
|
|
}
|
|
|
|
# Remove Entry from Windows Installer, if it is owned by this installation.
|
|
try {
|
|
$item = Get-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Bun";
|
|
$location = $item.GetValue("InstallLocation");
|
|
if ($location -eq "${PSScriptRoot}") {
|
|
Remove-Item "HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\Bun" -Recurse
|
|
}
|
|
} catch {
|
|
# unlucky tbh
|
|
}
|