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 all 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
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ brew install protobuf # macOS
cargo install deno
```

## Install Globally

**With PowerShell:**

```powershell
$denoGlobalInstall; irm https://deno.land/install.ps1 | iex
```

## Install and Manage Multiple Versions

**With [asdf](https://asdf-vm.com) and [asdf-deno](https://github.com/asdf-community/asdf-deno):**
Expand Down Expand Up @@ -178,3 +186,4 @@ During the `install.sh` process, `unzip` or `7z` is used to extract the zip arch
**How can this issue be fixed?**

You can install unzip via `brew install unzip` on MacOS or `apt-get install unzip -y` on Linux.

20 changes: 13 additions & 7 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@

$ErrorActionPreference = 'Stop'

if ($v) {
$Version = "v${v}"
}
if ($Args.Length -eq 1) {
$Version = $Args.Get(0)
$Version = $Args[0]
} elseif ($v) {
$Version = "v${v}"
}

$DenoInstall = $env:DENO_INSTALL
$BinDir = if ($DenoInstall) {
"${DenoInstall}\bin"
} elseif (Test-Path variable:\denoGlobalInstall) {
"${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:\denoGlobalInstall) {
[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
Loading