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

🩹 Ask to star fallback #420

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

🩹 Ask to star fallback #420

wants to merge 1 commit into from

Conversation

retlehs
Copy link
Member

@retlehs retlehs commented Dec 5, 2024

When running wp acorn acorn:install, at the last step you're prompted to star this repo. The command could fail in some instances, like when running the command from a Linux VM:

sh: 1: xdg-open: not found
INFO Thank you!

This PR adds a fallback to show the URL to this repo if the open command fails:

image

@retlehs retlehs self-assigned this Dec 5, 2024
$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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong about the behavior of shell_exec(), but afaik the first argument for start is the window title, i.e., start <title> <command>

Suggested change
'Windows' => shell_exec('start ' . $this->repoUrl . ' 2>nul') !== null,
'Windows' => shell_exec('start "" ' . $this->repoUrl . ' 2>nul') !== null,

If you just run start <url>, it will open a new cmd prompt with the URL as the title of the prompt.

start-url

Changing it to start "" <url> opens the URL in my default browser.

Again, I didn't test with shell_exec(), though, since I don't have PHP installed in Windows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants