Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add -g flag for global system install #284

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions install_global.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
$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 {
"${Env:ProgramFiles}\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

tar.exe xf $DenoZip -C $BinDir

Remove-Item $DenoZip

$Machine = [System.EnvironmentVariableTarget]::Machine
$Path = [System.Environment]::GetEnvironmentVariable("Path", $Machine)
Mqxx marked this conversation as resolved.
Show resolved Hide resolved
if (!(";${Path};".ToLower() -like "*;${BinDir};*".ToLower())) {
[System.Environment]::SetEnvironmentVariable("Path", "${Path};${BinDir}", $Machine)
$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"