From 07b161ab8fdc0adcf4c34b277336a5d81c3c2515 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Tue, 28 May 2024 07:34:50 +0200 Subject: [PATCH 1/6] Create install_global.ps1 --- install_global.ps1 | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 install_global.ps1 diff --git a/install_global.ps1 b/install_global.ps1 new file mode 100644 index 0000000..0fe57c8 --- /dev/null +++ b/install_global.ps1 @@ -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) +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" From 898fd90711f76d472acca0296afbcdecd4399f54 Mon Sep 17 00:00:00 2001 From: Mqxx <62719703+Mqxx@users.noreply.github.com> Date: Mon, 1 Jul 2024 07:55:02 +0200 Subject: [PATCH 2/6] Added flag for global install Removed old install_global.ps1 script --- install.ps1 | 21 +++++++++++++++------ install_global.ps1 | 46 ---------------------------------------------- 2 files changed, 15 insertions(+), 52 deletions(-) delete mode 100644 install_global.ps1 diff --git a/install.ps1 b/install.ps1 index e0fbac5..c4c93ab 100644 --- a/install.ps1 +++ b/install.ps1 @@ -4,11 +4,15 @@ $ErrorActionPreference = 'Stop' +param ( + [string]$v, + [switch]$g +) + if ($v) { $Version = "v${v}" -} -if ($Args.Length -eq 1) { - $Version = $Args.Get(0) +} elseif ($Args.Length -eq 1) { + $Version = $Args[0] } $DenoInstall = $env:DENO_INSTALL @@ -38,10 +42,15 @@ tar.exe xf $DenoZip -C $BinDir Remove-Item $DenoZip -$User = [System.EnvironmentVariableTarget]::User -$Path = [System.Environment]::GetEnvironmentVariable('Path', $User) +$EnvTarget = if ($g) { + [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}" } diff --git a/install_global.ps1 b/install_global.ps1 deleted file mode 100644 index 0fe57c8..0000000 --- a/install_global.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -$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) -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" From 545ece8793fd266b36c684b66fabc18b07506143 Mon Sep 17 00:00:00 2001 From: Mqxx <62719703+Mqxx@users.noreply.github.com> Date: Mon, 1 Jul 2024 08:49:00 +0200 Subject: [PATCH 3/6] Changed default install directory when global flag is set --- install.ps1 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/install.ps1 b/install.ps1 index c4c93ab..c340397 100644 --- a/install.ps1 +++ b/install.ps1 @@ -4,11 +4,6 @@ $ErrorActionPreference = 'Stop' -param ( - [string]$v, - [switch]$g -) - if ($v) { $Version = "v${v}" } elseif ($Args.Length -eq 1) { @@ -18,6 +13,8 @@ if ($v) { $DenoInstall = $env:DENO_INSTALL $BinDir = if ($DenoInstall) { "${DenoInstall}\bin" +} elseif (Test-Path variable:\g) { + "${Env:ProgramFiles}\deno\bin" } else { "${Home}\.deno\bin" } @@ -42,7 +39,7 @@ tar.exe xf $DenoZip -C $BinDir Remove-Item $DenoZip -$EnvTarget = if ($g) { +$EnvTarget = if (Test-Path variable:\g) { [System.EnvironmentVariableTarget]::Machine } else { [System.EnvironmentVariableTarget]::User From 1bae3704e6d3862bd5ced399202e42fd190e897f Mon Sep 17 00:00:00 2001 From: Mqxx <62719703+Mqxx@users.noreply.github.com> Date: Mon, 1 Jul 2024 08:50:03 +0200 Subject: [PATCH 4/6] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 00dda7f..8ff2463 100644 --- a/README.md +++ b/README.md @@ -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 +``` + ## Install Specific Version **With Shell:** From 1ed286ec0b6007ae72703697c98fd0dedabc4901 Mon Sep 17 00:00:00 2001 From: Mqx <62719703+Mqxx@users.noreply.github.com> Date: Mon, 8 Jul 2024 16:53:58 +0200 Subject: [PATCH 5/6] Review - Switched elseif - Changed `g` to `denoGlobalInstall` flag - Moved description to the bottom --- README.md | 16 ++++++++-------- install.ps1 | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8ff2463..b3bc910 100644 --- a/README.md +++ b/README.md @@ -18,14 +18,6 @@ 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 -``` - ## Install Specific Version **With Shell:** @@ -101,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):** diff --git a/install.ps1 b/install.ps1 index c340397..d0e7191 100644 --- a/install.ps1 +++ b/install.ps1 @@ -4,16 +4,16 @@ $ErrorActionPreference = 'Stop' -if ($v) { - $Version = "v${v}" -} elseif ($Args.Length -eq 1) { +if ($Args.Length -eq 1) { $Version = $Args[0] +} elseif ($v) { + $Version = "v${v}" } $DenoInstall = $env:DENO_INSTALL $BinDir = if ($DenoInstall) { "${DenoInstall}\bin" -} elseif (Test-Path variable:\g) { +} elseif (Test-Path variable:\denoGlobalInstall) { "${Env:ProgramFiles}\deno\bin" } else { "${Home}\.deno\bin" @@ -39,7 +39,7 @@ tar.exe xf $DenoZip -C $BinDir Remove-Item $DenoZip -$EnvTarget = if (Test-Path variable:\g) { +$EnvTarget = if (Test-Path variable:\denoGlobalInstall) { [System.EnvironmentVariableTarget]::Machine } else { [System.EnvironmentVariableTarget]::User From 465f7d7f0cc7172715554c9a02e81e3ad73e5c11 Mon Sep 17 00:00:00 2001 From: Mqxx <62719703+Mqxx@users.noreply.github.com> Date: Thu, 1 Aug 2024 08:09:49 +0200 Subject: [PATCH 6/6] Trigger Pipeline --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b3bc910..dd137b1 100644 --- a/README.md +++ b/README.md @@ -186,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. +