Skip to content

Instantly share code, notes, and snippets.

@sinkcup
Created October 21, 2019 03:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sinkcup/e66a02c2acf78b7e75878dd1f5bfa37c to your computer and use it in GitHub Desktop.
Save sinkcup/e66a02c2acf78b7e75878dd1f5bfa37c to your computer and use it in GitHub Desktop.
<?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