Skip to content

Instantly share code, notes, and snippets.

@marcelovani
Last active March 25, 2019 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcelovani/cd50061991cbbd7f83e4d45ae1649304 to your computer and use it in GitHub Desktop.
Save marcelovani/cd50061991cbbd7f83e4d45ae1649304 to your computer and use it in GitHub Desktop.
Used to update existing config
<?php
# This script replaces existing config on the current folder by copying from the origin provided as argument
# It also removes uuid and default_config hashes
if (empty($argv[1])) {
echo 'Please provide the origin folder' . PHP_EOL;
exit;
}
$origin = $argv[1];
$local = getcwd();
$files = array();
foreach (glob("$local/*.yml") as $file) {
$filename = basename($file);
if (file_exists("$origin/$filename")) {
$contents = file_get_contents("$origin/$filename");
$reg = "/_core:[\s\S].*default_config_hash.*\n|^uuid.*\n/";
$contents = preg_replace($reg, '', $contents);
file_put_contents("$local/$filename", $contents);
echo "Saved $filename\n";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment