Skip to content

Commit

Permalink
fixes some issues with always-install option
Browse files Browse the repository at this point in the history
  • Loading branch information
azt3k committed Aug 12, 2014
1 parent 25c6eb0 commit 15a448f
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/ABC/Composer/NonDestructiveArchiveInstallerInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public function update(InstalledRepositoryInterface $repo, PackageInterface $ini
$this->downloadAndExtractFile($package);
}

/**
* {@inheritDoc}
*/
public function isInstalled(InstalledRepositoryInterface $repo, PackageInterface $package) {
if ($this->alwaysInstall($package)) return false;
return parent::isInstalled($repo, $package);
}

/**
* {@inheritDoc}
*/
Expand All @@ -66,6 +74,13 @@ public function install(InstalledRepositoryInterface $repo, PackageInterface $pa
$this->downloadAndExtractFile($package);
}

protected function alwaysInstall(PackageInterface $package) {
$p_extra = $package->getExtra();
return isset($p_extra['always-install']) && strtolower($p_extra['always-install']) == "false"
? false
: true;
}

/**
* Downloads and extracts the package, only if the URL to download has not been downloaded before.
*
Expand All @@ -90,10 +105,6 @@ private function downloadAndExtractFile(PackageInterface $package) {
? strtolower($p_extra['omit-first-directory']) == "true"
: false;

$alwaysInstall = isset($p_extra['always-install']) && strtolower($p_extra['always-install']) == "false"
? false
: true;

$targetDir = isset($p_extra['target-dir'])
? realpath('./' . trim($p_extra['target-dir'], '/')) . '/'
: $this->getInstallPath($package);
Expand All @@ -112,7 +123,7 @@ private function downloadAndExtractFile(PackageInterface $package) {
}

// Has archive has been downloaded
if (self::getLastDownloadedFileUrl($package) == $url && !$alwaysInstall) return;
if (self::getLastDownloadedFileUrl($package) == $url && !$this->alwaysInstall($package)) return;

// SSL Check
if (!extension_loaded('openssl') && 0 === strpos($url, 'https:'))
Expand Down

0 comments on commit 15a448f

Please sign in to comment.