diff --git a/src/Tool/Command/PhiveInstallCommand.php b/src/Tool/Command/PhiveInstallCommand.php index 6058191f..790cad0f 100644 --- a/src/Tool/Command/PhiveInstallCommand.php +++ b/src/Tool/Command/PhiveInstallCommand.php @@ -20,14 +20,16 @@ public function __construct(string $alias, string $bin, ?string $sig = null) public function __toString(): string { $home = \sprintf('%s/.phive', \dirname($this->bin)); - $target = \dirname($this->bin); + $tmp = \sprintf('%s/tmp/%s', $home, \md5($this->alias)); return \sprintf( - 'phive --no-progress --home %s install %s %s -t %s', + 'phive --no-progress --home %s install %s %s -t %s && mv %s/* %s', $home, $this->sig ? '--trust-gpg-keys '.$this->sig : '--force-accept-unsigned', $this->alias, - $target + $tmp, + $tmp, + $this->bin ); } } diff --git a/tests/Tool/Command/PhiveInstallCommandTest.php b/tests/Tool/Command/PhiveInstallCommandTest.php index c92ce20f..79431528 100644 --- a/tests/Tool/Command/PhiveInstallCommandTest.php +++ b/tests/Tool/Command/PhiveInstallCommandTest.php @@ -26,12 +26,12 @@ public function test_it_is_a_command() public function test_it_generates_the_installation_command() { - $this->assertMatchesRegularExpression(\sprintf('#phive --no-progress --home [^\s]*? install --trust-gpg-keys %s %s -t [^\s]++#', self::SIG, self::ALIAS, self::BIN), (string) $this->command); + $this->assertMatchesRegularExpression(\sprintf('#phive --no-progress --home [^\s]*? install --trust-gpg-keys %s %s -t [^\s]++ && mv [^\s]+? %s#', self::SIG, self::ALIAS, self::BIN), (string) $this->command); } public function test_it_accepts_unsigned_phar_command() { $command = new PhiveInstallCommand(self::ALIAS, self::BIN); - $this->assertMatchesRegularExpression(\sprintf('#phive --no-progress --home [^\s]*? install --force-accept-unsigned %s -t [^\s]++#', self::ALIAS, self::BIN), (string) $command); + $this->assertMatchesRegularExpression(\sprintf('#phive --no-progress --home [^\s]*? install --force-accept-unsigned %s -t [^\s]++ && mv [^\s]+?#', self::ALIAS, self::BIN), (string) $command); } } diff --git a/tests/UseCase/InstallToolsTest.php b/tests/UseCase/InstallToolsTest.php index 91f79299..76efa84a 100644 --- a/tests/UseCase/InstallToolsTest.php +++ b/tests/UseCase/InstallToolsTest.php @@ -167,7 +167,7 @@ public function test_it_includes_phive_install_commands() ])); $command = $this->useCase->__invoke($this->filter()); - $this->assertMatchesRegularExpression('#phive --no-progress --home /tools/.phive install[^&]*?phpunit[^&]*? [^\s]++#', (string)$command); + $this->assertMatchesRegularExpression('#phive --no-progress --home /tools/.phive install[^&]*?phpunit[^&]*? [^\s]++ && mv [^\s]++ /tools/phpunit#', (string)$command); } public function test_it_includes_file_download_commands()