From 89ab92a16c6d4a54139f788541f75ef08332b6ef Mon Sep 17 00:00:00 2001 From: Malik Kotob Date: Tue, 28 Mar 2017 09:00:21 -0400 Subject: [PATCH] Fixes #915: Sync drushrc.php with template drushrc.php via update hook. --- src/Update/Updater.php | 22 ++++++++++++++++++++++ src/Update/Updates.php | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/src/Update/Updater.php b/src/Update/Updater.php index 111533b61..44b9b1ffc 100644 --- a/src/Update/Updater.php +++ b/src/Update/Updater.php @@ -10,6 +10,7 @@ use Symfony\Component\Console\Helper\FormatterHelper; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Filesystem\Exception\FileNotFoundException; +use Symfony\Component\Filesystem\Exception\IOException; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Process\Process; use Symfony\Component\Yaml\Yaml; @@ -478,6 +479,27 @@ public function moveFile($source, $target, $overwrite = FALSE) { return FALSE; } + /** + * Copies a file from the BLT template to the repository. + * + * @param string $source + * The filepath, relative to the BLT template directory. + */ + public function syncWithTemplate($filePath, $overwrite = FALSE) { + $sourcePath = $this->getBltRoot() . '/template/' . $filePath; + $targetPath = $this->getRepoRoot() . '/' . $filePath; + + if ($this->getFileSystem()->exists($sourcePath)) { + try { + $this->getFileSystem()->copy($sourcePath, $targetPath, $overwrite); + } + catch (IOException $e) { + throw $e; + } + } + + } + /** * Performs a find and replace in a text file. * diff --git a/src/Update/Updates.php b/src/Update/Updates.php index 1e4da7e62..f08d5d9c3 100644 --- a/src/Update/Updates.php +++ b/src/Update/Updates.php @@ -278,5 +278,9 @@ public function update_8007000() { $this->updater->getOutput()->writeln($formattedBlock); $this->updater->getOutput()->writeln(""); $this->updater->getOutput()->writeln("Please execute `composer update` to incorporate these final automated changes to composer.json."); + + // Sync updates to drushrc.php manually since it has been added to ignore-existing.txt. + $drushrcFile = 'drush/drushrc.php'; + $this->updater->syncWithTemplate($drushrcFile, TRUE); } }