Skip to content

Commit

Permalink
Slightly better code readability in init command.
Browse files Browse the repository at this point in the history
  • Loading branch information
weitzman committed Sep 22, 2017
1 parent 1921f17 commit e1e5870
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/Commands/core/InitCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ class InitCommands extends DrushCommands implements BuilderAwareInterface, IOAwa
* @usage core-init --edit --bg
* Return to shell prompt as soon as the editor window opens
*/
public function initializeDrush($options = [
'edit' => '',
'add-path' => '',
])
public function initializeDrush($options = ['edit' => '', 'add-path' => ''])
{
$home = drush_server_home();
$drush_config_dir = $home . "/.drush";
Expand All @@ -48,23 +45,20 @@ public function initializeDrush($options = [
$collection = $this->collectionBuilder();

// Create a ~/.drush directory if it does not yet exist
$collection->taskFilesystemStack()
->mkdir($drush_config_dir);
$collection->taskFilesystemStack()->mkdir($drush_config_dir);

// If there is no ~/.drush/drushrc.php, then copy the
// example Drush configuration file here
if (!is_file($drush_config_file)) {
$collection->taskWriteToFile($drush_config_file)
->textFromFile($example_configuration);
$collection->taskWriteToFile($drush_config_file)->textFromFile($example_configuration);
}

// Decide whether we want to add our Bash commands to
// ~/.bashrc or ~/.bash_profile, and create a task to
// update it with includes of the various files we write,
// as needed. If it is, then we will add it to the collection.
$bashrc = $this->findBashrc($home);
$taskUpdateBashrc = $this->taskWriteToFile($bashrc)
->append();
$taskUpdateBashrc = $this->taskWriteToFile($bashrc)->append();

// List of Drush bash configuration files, and
// their source templates.
Expand All @@ -84,8 +78,7 @@ public function initializeDrush($options = [
// If the destination file does not exist, then
// copy the example file there.
if (!is_file($destFile)) {
$collection->taskWriteToFile($destFile)
->textFromFile($sourceFile);
$collection->taskWriteToFile($destFile)->textFromFile($sourceFile);
$description = $drushBashFileDescriptions[$destFile];
$collection->progressMessage('Copied {description} to {path}', ['description' => $description, 'path' => $destFile], LogLevel::OK);
$pattern = basename($destFile);
Expand Down

0 comments on commit e1e5870

Please sign in to comment.