This is an automated email from the ASF dual-hosted git repository.

msciabarra pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/openserverless-cli.git


The following commit(s) were added to refs/heads/main by this push:
     new 8fb8366  better detection of the os
8fb8366 is described below

commit 8fb8366d79118d782e9ce1883a7ada3a07dfe661
Author: Michele Sciabarra <[email protected]>
AuthorDate: Fri Aug 9 10:55:21 2024 +0200

    better detection of the os
---
 README.md   |  2 +-
 install.ps1 | 61 ++++++++++++++++++++++++++++++-------------------------------
 2 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/README.md b/README.md
index b7dec69..bc23789 100644
--- a/README.md
+++ b/README.md
@@ -38,7 +38,7 @@ Well, as you can guess it helps with operations: `ops` is the 
OpenServerless CLI
 
 It is a task executor on steroids. 
 
-- it embeds [`task`](https://taskfile.dev))
+- it embeds [`task`](https://taskfile.dev)
 - it embeds [`wsk`](https://github.com/apache/openwhisk-cli)
 - it embeds a lot of other utility commands (check with `ops -help`)
 - automatically download and updated commad line tools he neeeds as 
prerequisites
diff --git a/install.ps1 b/install.ps1
index 7dd4097..321ee66 100644
--- a/install.ps1
+++ b/install.ps1
@@ -15,38 +15,37 @@
 # specific language governing permissions and limitations
 # under the License.
 
-$OS = (uname -s)
-$ARCH = (uname -m)
-$CMD = "ops"
-$WINDOWS = $false
+$SUFFIX = "_windows_amd64"
+$EXT = ".zip"
+$CMD = "ops.exe"
 
-switch ("$OS-$ARCH") {
-    "Linux-x86_64" {
-        $SUFFIX = "_linux_amd64"
-        $EXT = ".tar.gz"
+if (-not $IsWindows) {
+    $OS = (uname -s)
+    $ARCH = (uname -m)
+    $CMD = "ops"
+    switch ("$OS-$ARCH") {
+        "Linux-x86_64" {
+            $SUFFIX = "_linux_amd64"
+            $EXT = ".tar.gz"
+        }
+        "Linux-arm64" {
+            $SUFFIX = "_linux_arm64"
+            $EXT = ".tar.gz"
+        }
+        "Darwin-x86_64" {
+            $SUFFIX = "_darwin_amd64"
+            $EXT = ".tar.gz"
+        }
+        "Darwin-arm64" {
+            $SUFFIX = "_darwin_arm64"
+            $EXT = ".tar.gz"
+        }
+        default {
+            Write-Host "Unknown system - exiting"
+            exit 1
+        }
     }
-    "Linux-arm64" {
-        $SUFFIX = "_linux_arm64"
-        $EXT = ".tar.gz"
-    }
-    "Darwin-x86_64" {
-        $SUFFIX = "_darwin_amd64"
-        $EXT = ".tar.gz"
-    }
-    "Darwin-arm64" {
-        $SUFFIX = "_darwin_arm64"
-        $EXT = ".tar.gz"
-    }
-    { $_ -like "MINGW64_NT-*" } {
-        $SUFFIX = "_windows_amd64"
-        $EXT = ".zip"
-        $CMD = "ops.exe"
-    }
-    default {
-        Write-Host "Unknown system - exiting"
-        exit 1
-    }
-}
+} 
 
 $OPSROOT = 
"https://raw.githubusercontent.com/apache/openserverless-task/0.1.0/opsroot.json";
 $VERSION = (Invoke-RestMethod -Uri $OPSROOT).version
@@ -78,7 +77,7 @@ if (-not (Test-Path "$BinPath/$CMD*")) {
 
 # Check if the bin path is in the user's PATH
 if (-not ($env:PATH -contains $BinPath)) {
-    if($WINDOWS) {
+    if($IsWindows) {
         $existingPath = [System.Environment]::GetEnvironmentVariable("Path", 
[System.EnvironmentVariableTarget]::User)
             $newPath = "$BinPath;$existingPath"
             [System.Environment]::SetEnvironmentVariable("Path", $newPath, 
[System.EnvironmentVariableTarget]::User)

Reply via email to