Skip to content

Commit

Permalink
Fixes #915: Sync drushrc.php with template drushrc.php via update hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
malikkotob committed Mar 28, 2017
1 parent 473d91b commit 89ab92a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Update/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand Down
4 changes: 4 additions & 0 deletions src/Update/Updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -278,5 +278,9 @@ public function update_8007000() {
$this->updater->getOutput()->writeln($formattedBlock);
$this->updater->getOutput()->writeln("");
$this->updater->getOutput()->writeln("<comment>Please execute `composer update` to incorporate these final automated changes to composer.json.</comment>");

// Sync updates to drushrc.php manually since it has been added to ignore-existing.txt.
$drushrcFile = 'drush/drushrc.php';
$this->updater->syncWithTemplate($drushrcFile, TRUE);
}
}

0 comments on commit 89ab92a

Please sign in to comment.