-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathComposer.php
52 lines (47 loc) · 1.36 KB
/
Composer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace ParagonIE\Certainty;
use Composer\Script\Event;
/**
* Class Composer
* @package ParagonIE\Certainty
*/
class Composer
{
/**
* @param Event $event
*
* @throws Exception\CertaintyException
* @throws \SodiumException
* @return void
* @psalm-suppress UnresolvableInclude
*/
public static function postAutoloadDump(Event $event)
{
if (\getenv('TRAVIS')) {
// GnuTLS error
return;
}
/** @var string $vendorDir */
$vendorDir = $event->getComposer()->getConfig()->get('vendor-dir');
require_once $vendorDir . '/autoload.php';
$dataDir = \dirname($vendorDir) . '/data';
(new RemoteFetch($dataDir))->getLatestBundle(false, false);
self::dos2unixAll($dataDir);
(new RemoteFetch($dataDir))->getLatestBundle();
echo '[OK] Remote Fetch of latest CACert Bundle', PHP_EOL;
}
/**
* Prevent newline weirdness with Git from causing invalid files (SHA-256, signatures)
*
* @param string $dataDir
* @return void
*/
public static function dos2unixAll($dataDir)
{
foreach (glob($dataDir . '/*.pem') as $pemFile) {
$contents = file_get_contents($pemFile);
$fixed = str_replace("\r\n", "\n", $contents);
file_put_contents($pemFile, $fixed);
}
}
}