-
Notifications
You must be signed in to change notification settings - Fork 114
Improved the way we display the executed installer command #88
Conversation
@@ -562,6 +562,9 @@ private function getExecutedCommand() | |||
$version = $this->version; | |||
} | |||
|
|||
return sprintf('%s new %s %s', $_SERVER['PHP_SELF'], $this->projectName, $version); | |||
$executedCommand = $_SERVER['PHP_SELF']; | |||
$executedCommand = preg_replace('~/usr/local/bin/~', '', $executedCommand); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could be even smarter and check if dirname()
of $_SERVER['PHP_SELF']
is one of the paths in $_SERVER['PATH']
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea! Done in 860c9b9.
*/ | ||
private function getExecutedCommand() | ||
{ | ||
$pathDirs = explode(':', $_SERVER['PATH']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the colon also used on Windows? I thought it was a semicolon there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch Christian. I've just replaced this by a preg_split()
call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But wouldn't this now break on Windows with paths containing something like C:\...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course :( I'm really ashamed of my self for not having used PATH_SEPARATOR
constant from the very beginning. Hopefully this is fixed for real now.
$executedCommandDir = dirname($executedCommand); | ||
|
||
if (in_array($executedCommandDir, $pathDirs)) { | ||
$executedCommand = str_replace($executedCommandDir, '', $executedCommand); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using str_replace()
here is dangerous if the user stores the installer, for example, in /symfony/symfony
. executedCommand
will then be an empty string in the end. You could use basename()
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree! Your proposal is the right thing to do. Thanks!
👍 |
This PR tries to solve #80 for the most used case. Around 80% of users use Linux or Mac and most of them will install the installer in
/usr/local/bin/
, so we can easily improve commands' output.