Skip to content
This repository was archived by the owner on Nov 14, 2019. It is now read-only.

Commit 363a1ed

Browse files
committed
minor #88 Improved the way we display the executed installer command (javiereguiluz)
This PR was squashed before being merged into the 1.0-dev branch (closes #88). Discussion ---------- Improved the way we display the executed installer command 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. Commits ------- 576b71d Improved the way we display the executed installer command
2 parents 40923b5 + 576b71d commit 363a1ed

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/Symfony/Installer/AboutCommand.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,25 @@ protected function execute(InputInterface $input, OutputInterface $output)
8181
$output->writeln(sprintf($commandHelp,
8282
$this->appVersion,
8383
str_repeat('=', 20 + strlen($this->appVersion)),
84-
$_SERVER['PHP_SELF']
84+
$this->getExecutedCommand()
8585
));
8686
}
87+
88+
/**
89+
* Returns the executed command.
90+
*
91+
* @return string
92+
*/
93+
private function getExecutedCommand()
94+
{
95+
$pathDirs = explode(PATH_SEPARATOR, $_SERVER['PATH']);
96+
$executedCommand = $_SERVER['PHP_SELF'];
97+
$executedCommandDir = dirname($executedCommand);
98+
99+
if (in_array($executedCommandDir, $pathDirs)) {
100+
$executedCommand = basename($executedCommand);
101+
}
102+
103+
return $executedCommand;
104+
}
87105
}

src/Symfony/Installer/NewCommand.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,14 @@ private function getExecutedCommand()
562562
$version = $this->version;
563563
}
564564

565-
return sprintf('%s new %s %s', $_SERVER['PHP_SELF'], $this->projectName, $version);
565+
$pathDirs = explode(PATH_SEPARATOR, $_SERVER['PATH']);
566+
$executedCommand = $_SERVER['PHP_SELF'];
567+
$executedCommandDir = dirname($executedCommand);
568+
569+
if (in_array($executedCommandDir, $pathDirs)) {
570+
$executedCommand = basename($executedCommand);
571+
}
572+
573+
return sprintf('%s new %s %s', $executedCommand, $this->projectName, $version);
566574
}
567575
}

0 commit comments

Comments
 (0)