Skip to content

Instantly share code, notes, and snippets.

@mnakka9
Created July 10, 2022 15:57
Show Gist options
  • Select an option

  • Save mnakka9/e6f81f1fe14f4b54918766e36159d198 to your computer and use it in GitHub Desktop.

Select an option

Save mnakka9/e6f81f1fe14f4b54918766e36159d198 to your computer and use it in GitHub Desktop.
#!/usr/bin/env pwsh
# Copyright 2018 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'
# GitHub requires TLS 1.2
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$DenoUri = 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
}
wget $DenoUri -OutFile $DenoZip
Expand-Archive -Path $DenoZip -DestinationPath $BinDir -Force
Remove-Item $DenoZip
$User = [EnvironmentVariableTarget]::User
$Path = [Environment]::GetEnvironmentVariable('Path', $User)
if (!(";$Path;".ToLower() -like "*;$BinDir;*".ToLower())) {
[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"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment