Last active
April 26, 2024 13:09
-
-
Save beetcb/84ea3cc0c6b64cf39fd77c85461a71fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env pwsh | |
# Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. | |
# TODO(everyone): Keep this script simple and easily auditable. | |
$ErrorActionPreference = 'Stop' | |
if ($v) { | |
$Version = "v${v}" | |
} | |
if ($Args.Length -eq 1) { | |
$Version = $Args.Get(0) | |
} | |
$DenoInstall = $env:DENO_INSTALL | |
$BinDir = if ($DenoInstall) { | |
"${DenoInstall}\bin" | |
} else { | |
"${Home}\.deno\bin" | |
} | |
$DenoZip = "$BinDir\deno.zip" | |
$DenoExe = "$BinDir\deno.exe" | |
$Target = 'x86_64-pc-windows-msvc' | |
$DownloadUrl = if (!$Version) { | |
"https://github.com/denoland/deno/releases/latest/download/deno-${Target}.zip" | |
} else { | |
"https://github.com/denoland/deno/releases/download/${Version}/deno-${Target}.zip" | |
} | |
if (!(Test-Path $BinDir)) { | |
New-Item $BinDir -ItemType Directory | Out-Null | |
} | |
curl.exe -Lo $DenoZip $DownloadUrl | |
unzip $DenoZip -d $BinDir | |
Remove-Item $DenoZip | |
$User = [System.EnvironmentVariableTarget]::User | |
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User) | |
if (!(";${Path};".ToLower() -like "*;${BinDir};*".ToLower())) { | |
[System.Environment]::SetEnvironmentVariable('Path', "${Path};${BinDir}", $User) | |
$Env:Path += ";${BinDir}" | |
} | |
Write-Output "Deno was installed successfully to ${DenoExe}" | |
Write-Output "Run 'deno --help' to get started" | |
Write-Output "Stuck? Join our Discord https://discord.gg/deno" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment