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
Show file tree
Hide file tree
Changes from 4 commits
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
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ curl -fsSL https://deno.land/install.sh | sh
irm https://deno.land/install.ps1 | iex
```

## Install Globally

**With PowerShell:**

```powershell
$g; irm https://deno.land/install.ps1 | iex
```
Mqxx marked this conversation as resolved.
Show resolved Hide resolved

## Install Specific Version

**With Shell:**
Expand Down
18 changes: 12 additions & 6 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ $ErrorActionPreference = 'Stop'

if ($v) {
$Version = "v${v}"
}
if ($Args.Length -eq 1) {
$Version = $Args.Get(0)
} elseif ($Args.Length -eq 1) {
Mqxx marked this conversation as resolved.
Show resolved Hide resolved
$Version = $Args[0]
}

$DenoInstall = $env:DENO_INSTALL
$BinDir = if ($DenoInstall) {
"${DenoInstall}\bin"
} elseif (Test-Path variable:\g) {
"${Env:ProgramFiles}\deno\bin"
} else {
"${Home}\.deno\bin"
}
Expand All @@ -38,10 +39,15 @@ tar.exe xf $DenoZip -C $BinDir

Remove-Item $DenoZip

$User = [System.EnvironmentVariableTarget]::User
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
$EnvTarget = if (Test-Path variable:\g) {
Mqxx marked this conversation as resolved.
Show resolved Hide resolved
[System.EnvironmentVariableTarget]::Machine
} else {
[System.EnvironmentVariableTarget]::User
}

$Path = [System.Environment]::GetEnvironmentVariable('Path', $EnvTarget)
if (!(";${Path};".ToLower() -like "*;${BinDir};*".ToLower())) {
[System.Environment]::SetEnvironmentVariable('Path', "${Path};${BinDir}", $User)
[System.Environment]::SetEnvironmentVariable('Path', "${Path};${BinDir}", $EnvTarget)
$Env:Path += ";${BinDir}"
}

Expand Down