From 24b97a391f8b5150f943119e162c4e94bbdc9a47 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Thu, 11 Mar 2021 11:26:55 +0400 Subject: [PATCH 1/3] Support for macOS. --- Splitter.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Splitter.php b/Splitter.php index ad96143..5741d02 100644 --- a/Splitter.php +++ b/Splitter.php @@ -10,18 +10,21 @@ class Splitter { const SPLITSH_NAME = 'splitsh-lite'; - const SPLITSH_URL = 'https://github.com/splitsh/lite/releases/download/v1.0.1/lite_linux_amd64.tar.gz'; - const BIN_FILES = array( - 'splitsh-lite' => 'https://github.com/splitsh/lite/releases/download/v1.0.1/lite_linux_amd64.tar.gz', - ); + const SPLITSH_URL = [ + 'Linux' => 'https://github.com/splitsh/lite/releases/download/v1.0.1/lite_linux_amd64.tar.gz', + 'Darwin' => 'https://github.com/splitsh/lite/releases/download/v1.0.1/lite_darwin_amd64.tar.gz', + ]; /** * Install splitsh-lite script. */ static function install($bin_dir = 'bin') { - $name = self::SPLITSH_NAME; - $url = self::SPLITSH_URL; + $os = PHP_OS_FAMILY; + if (!isset(self::SPLITSH_URL[$os])) { + throw new \LogicException("There's no splitsh-lite version for '{$os}' operating system."); + } + $url = self::SPLITSH_URL[$os]; // @TODO: Load BIN path from composer project bin path. $bin_path = "{$bin_dir}/{$name}"; From fca1de41c3cf2787358a4f76ac207a0b1c642c44 Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Thu, 11 Mar 2021 13:57:43 +0400 Subject: [PATCH 2/3] Remove useless var. --- Splitter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Splitter.php b/Splitter.php index 5741d02..7e6ce48 100644 --- a/Splitter.php +++ b/Splitter.php @@ -21,10 +21,10 @@ class Splitter { static function install($bin_dir = 'bin') { $name = self::SPLITSH_NAME; $os = PHP_OS_FAMILY; - if (!isset(self::SPLITSH_URL[$os])) { - throw new \LogicException("There's no splitsh-lite version for '{$os}' operating system."); + if (!isset(self::SPLITSH_URL[PHP_OS_FAMILY])) { + throw new \LogicException("There's no splitsh-lite version for '" . PHP_OS_FAMILY . "' operating system."); } - $url = self::SPLITSH_URL[$os]; + $url = self::SPLITSH_URL[PHP_OS_FAMILY]; // @TODO: Load BIN path from composer project bin path. $bin_path = "{$bin_dir}/{$name}"; From 06b6eb708a723dfa64371021dae48fc30c79ac9a Mon Sep 17 00:00:00 2001 From: Claudiu Cristea Date: Fri, 12 Mar 2021 23:57:15 +0400 Subject: [PATCH 3/3] Support PHP <7.2 --- Splitter.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Splitter.php b/Splitter.php index 7e6ce48..b3cc0c6 100644 --- a/Splitter.php +++ b/Splitter.php @@ -19,12 +19,13 @@ class Splitter { * Install splitsh-lite script. */ static function install($bin_dir = 'bin') { + $name = self::SPLITSH_NAME; - $os = PHP_OS_FAMILY; - if (!isset(self::SPLITSH_URL[PHP_OS_FAMILY])) { - throw new \LogicException("There's no splitsh-lite version for '" . PHP_OS_FAMILY . "' operating system."); + $os = php_uname('s'); + if (!isset(self::SPLITSH_URL[$os])) { + throw new \LogicException("There's no splitsh-lite version for '{$os}' operating system."); } - $url = self::SPLITSH_URL[PHP_OS_FAMILY]; + $url = self::SPLITSH_URL[$os]; // @TODO: Load BIN path from composer project bin path. $bin_path = "{$bin_dir}/{$name}";