Last active
March 25, 2019 16:23
-
-
Save marcelovani/cd50061991cbbd7f83e4d45ae1649304 to your computer and use it in GitHub Desktop.
Used to update existing config
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 | |
# 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