Skip to content

Commit

Permalink
Fixes #915: Sync drushrc.php with template drushrc.php via update hoo…
Browse files Browse the repository at this point in the history
…k. (#1265)

* Add policy.drush.inc to remove deprecated script.

* Fixes #915: Sync drushrc.php with template drushrc.php via update hook.
  • Loading branch information
malikkotob authored and grasmash committed Mar 28, 2017
1 parent b7f9c95 commit 9719bf3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions scripts/blt/remove-deprecated.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ rm -f readme/project-tasks.md
rm -f readme/release-process.md
rm -f readme/repo-architecture.md
rm -f readme/views.md
rm -f drush/policy.drush.inc
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 9719bf3

Please sign in to comment.