Created
October 21, 2019 03:12
-
-
Save sinkcup/e66a02c2acf78b7e75878dd1f5bfa37c to your computer and use it in GitHub Desktop.
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
<?php | |
/** | |
* remove mirros of composer.lock | |
*/ | |
$data = json_decode(file_get_contents(__DIR__ . '/composer.lock'), true); | |
$new_data = $data; | |
foreach (['packages', 'packages-dev'] as $key) { | |
if (!isset($data[$key])) { | |
continue; | |
} | |
$new_data[$key] = []; | |
foreach ($data[$key] as $package) { | |
unset($package['dist']['mirrors']); | |
$new_data[$key][] = $package; | |
} | |
} | |
$new_contents = json_encode($new_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n"; | |
if (in_array('-i', $argv)) { | |
file_put_contents(__DIR__ . '/composer.lock', $new_contents); | |
} else { | |
echo $new_contents; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment