This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
forked from civicrm/composer-downloads-plugin
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from tienvx/test-zip-handler
Test zip handler
- Loading branch information
Showing
9 changed files
with
307 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
namespace LastCall\DownloadsPlugin; | ||
|
||
use Composer\Installer\BinaryInstaller; | ||
use Composer\IO\IOInterface; | ||
use Composer\Util\Platform; | ||
use Composer\Util\ProcessExecutor; | ||
|
||
class BinariesInstaller | ||
{ | ||
public function install(Subpackage $subpackage, string $baseDir, IOInterface $io): void | ||
{ | ||
foreach ($subpackage->getBinaries() as $bin) { | ||
$path = $baseDir.\DIRECTORY_SEPARATOR.$bin; | ||
if (Platform::isWindows() || (method_exists(Platform::class, 'isWindowsSubsystemForLinux') ? Platform::isWindowsSubsystemForLinux() : false)) { | ||
$proxy = $path.'.bat'; | ||
if (file_exists($proxy)) { | ||
$io->writeError(' Skipped installation of bin '.$bin.'.bat proxy for package '.$subpackage->getName().': a .bat proxy was already installed'); | ||
} else { | ||
$caller = BinaryInstaller::determineBinaryCaller($path); | ||
file_put_contents($proxy, '@'.$caller.' "%~dp0'.ProcessExecutor::escape(basename($proxy, '.bat')).'" %*'); | ||
} | ||
} else { | ||
chmod($path, 0777 ^ umask()); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace LastCall\DownloadsPlugin\Tests\Unit\Handler; | ||
|
||
abstract class ArchiveHandlerTestCase extends BaseHandlerTestCase | ||
{ | ||
public function getBinariesTests(): array | ||
{ | ||
return [ | ||
[null, []], | ||
[[], []], | ||
[['bin/file1'], ['bin/file1']], | ||
[['bin/file1', 'bin/file2'], ['bin/file1', 'bin/file2']], | ||
]; | ||
} | ||
|
||
public function getInvalidBinariesTests(): array | ||
{ | ||
return [ | ||
[true, 'bool'], | ||
[false, 'bool'], | ||
[123, 'int'], | ||
[12.3, 'float'], | ||
['test', 'string'], | ||
[(object) ['key' => 'value'], 'stdClass'], | ||
]; | ||
} | ||
} |
Oops, something went wrong.