From 4217bbe4ec0067919497dcdbc040bb1b9f9cc79d Mon Sep 17 00:00:00 2001 From: Ben Word Date: Thu, 5 Dec 2024 14:54:38 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A9=B9=20Ask=20to=20star=20fallback?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Console/Commands/AcornInstallCommand.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Roots/Acorn/Console/Commands/AcornInstallCommand.php b/src/Roots/Acorn/Console/Commands/AcornInstallCommand.php index 39435a53..e4376428 100644 --- a/src/Roots/Acorn/Console/Commands/AcornInstallCommand.php +++ b/src/Roots/Acorn/Console/Commands/AcornInstallCommand.php @@ -24,6 +24,13 @@ class AcornInstallCommand extends Command */ protected $description = 'Install Acorn into the application'; + /** + * The Acorn repository URL. + * + * @var string + */ + protected $repoUrl = 'https://github.com/roots/acorn'; + /** * Execute the console command. */ @@ -119,12 +126,18 @@ protected function askToStar(): void label: '🎉 All done! Would you like to show love by starring Acorn on GitHub?', default: true, )) { - match (PHP_OS_FAMILY) { - 'Darwin' => exec('open https://github.com/roots/acorn'), - 'Linux' => exec('xdg-open https://github.com/roots/acorn'), - 'Windows' => exec('start https://github.com/roots/acorn'), + $opened = match (PHP_OS_FAMILY) { + 'Darwin' => shell_exec('open ' . $this->repoUrl . ' 2>/dev/null') !== null, + 'Linux' => shell_exec('xdg-open ' . $this->repoUrl . ' 2>/dev/null') !== null, + 'Windows' => shell_exec('start ' . $this->repoUrl . ' 2>nul') !== null, + default => false, }; + if (!$opened) { + $this->components->info('Please visit this URL to star the repository:'); + $this->components->info($this->repoUrl); + } + $this->components->info('Thank you!'); } }