Skip to content

Commit

Permalink
Correctly set Phar path for self update. (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash authored Jun 10, 2020
1 parent c5c342e commit 03f2194
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/Command/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Webmozart\PathUtil\Path;

/**
* Class UpdateCommand.
Expand Down Expand Up @@ -41,8 +42,7 @@ protected function commandRequiresAuthentication(): bool {
*/
protected function execute(InputInterface $input, OutputInterface $output) {
if (!$this->getPharPath()) {
throw new RuntimeException('update only works when running the phar version of ' . $this->getApplication()
->getName() . '.');
throw new RuntimeException('update only works when running the phar version of ' . $this->getApplication()->getName() . '.');
}

$updater = new Updater($this->getPharPath(), FALSE);
Expand Down Expand Up @@ -73,7 +73,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
*/
public function getPharPath(): string {
if (!isset($this->pharPath)) {
$this->pharPath = Phar::running(TRUE);
$this->setPharPath(Phar::running(FALSE));
}
return $this->pharPath;
}
Expand All @@ -82,7 +82,7 @@ public function getPharPath(): string {
* @param string $pharPath
*/
public function setPharPath(string $pharPath): void {
$this->pharPath = $pharPath;
$this->pharPath = Path::canonicalize($pharPath);
}

}
10 changes: 2 additions & 8 deletions src/SelfUpdate/Strategy/GithubStrategy.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
<?php
/**
* This class is partially patterned after Composer's self-update.
*/

namespace Acquia\Cli\SelfUpdate\Strategy;

use Acquia\Cli\Exception\AcquiaCliException;
use Humbug\SelfUpdate\Exception\HttpRequestException;
use Humbug\SelfUpdate\Exception\JsonParsingException;
use Humbug\SelfUpdate\Strategy\StrategyInterface;
use Humbug\SelfUpdate\Updater;
use Humbug\SelfUpdate\VersionParser;

class GithubStrategy extends \Humbug\SelfUpdate\Strategy\GithubStrategy implements StrategyInterface
{
const API_URL = 'https://api.github.com/repos/%s/releases';
class GithubStrategy extends \Humbug\SelfUpdate\Strategy\GithubStrategy {
public const API_URL = 'https://api.github.com/repos/%s/releases';

/**
* @var string
Expand Down
1 change: 1 addition & 0 deletions tests/phpunit/src/Commands/UpdateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function testNonPharException(): void {

/**
* @requires OS linux|darwin
* @throws \Exception
*/
public function testDownloadUpdate(): void {

Expand Down

0 comments on commit 03f2194

Please sign in to comment.