Skip to content

Commit

Permalink
Issue drush-ops#20: Add feedback on success or failure of drush dl co…
Browse files Browse the repository at this point in the history
…mmand.
  • Loading branch information
serundeputy committed Feb 21, 2016
1 parent 0143ae1 commit 9080cb5
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion commands/backdrop_pm.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ function drush_backdrop_pm_download() {
exec(
"rm $project_path/$projects[0].zip"
);
drush_dl_outcome($project_path, $projects[0]);
}
else {
foreach ($projects as $project) {
Expand Down Expand Up @@ -109,8 +110,13 @@ function drush_backdrop_pm_download() {
exec(
"rm $project_path/$project.zip"
);
drush_dl_outcome($module_install_location, $project);
}
// Downloading backdrop itself is a special case.
// TODO: Downloading backdrop itself does not currently work since
// the backdrop drush command hooks are only picked up once a valid
// backdrop installation is detected, so we have a chicken and the egg
// problem here.
elseif ($project == 'backdrop') {
$html = drush_backdrop_get_from_github(
"https://github.com/backdrop/backdrop/releases/latest"
Expand All @@ -134,7 +140,7 @@ function drush_backdrop_pm_download() {
"rm backdrop.zip"
);
}
drush_log(dt('Successfully downloaded.'));
drush_dl_outcome('.', 'Backdrop CMS');
}
}
}
Expand Down Expand Up @@ -187,3 +193,21 @@ function drush_backdrop_get_path($tags) {
}
return $project_path;
}

/**
* Determine success or failure of drush dl command and give the user some
* relevent feedback.
* @param string $module_install_location
* String directory path where module should end up.
*
* @param string $project
* Project name.
*/
function drush_dl_outcome($module_install_location, $project) {
if (file_exists($module_install_location)) {
print "\n\t\033[32m Success: \033[0m Project $project downloaded to $module_install_location.\n\n";
}
else {
print "\n\t\033[31m Error: \033[0m Project $project could not be found.\n\n";
}
}

0 comments on commit 9080cb5

Please sign in to comment.