You are here

function respondjs_drush_respondjs_download in Respond.js 7

Same name and namespace in other branches
  1. 8 drush/respondjs.drush.inc \respondjs_drush_respondjs_download()

This is where the action takes place.

In this function, all of Drupals API is (usually) available, including any functions you have added in your own modules/themes.

To print something to the terminal window, use drush_print().

1 call to respondjs_drush_respondjs_download()
drush_respondjs_post_pm_enable in drush/respondjs.drush.inc
Implements drush_MODULE_post_COMMAND().
1 string reference to 'respondjs_drush_respondjs_download'
respondjs_drush_command in drush/respondjs.drush.inc
Implementation of hook_drush_command().

File

drush/respondjs.drush.inc, line 62
drush integration for respondjs.

Code

function respondjs_drush_respondjs_download() {
  $args = func_get_args();
  if (isset($args[0])) {
    $path = $args[0];
  }
  else {
    if (function_exists('libraries_get_path') && libraries_get_path('respondjs')) {
      $path = libraries_get_path('respondjs');
    }
    else {
      $path = RESPONDJS_DOWNLOAD_LOCATION;
    }
  }

  // Create the path if it does not exist yet.
  if (!is_dir($path)) {
    drush_mkdir($path);
  }

  // Download the file and report back
  if (is_file($path . '/respond.min.js')) {
    drush_log('Respond.js already present. No download required.', 'ok');
    return TRUE;
  }
  elseif (drush_op('chdir', $path) && (drush_shell_exec('curl -O ' . RESPONDJS_DOWNLOAD_URI) || drush_shell_exec('wget --no-check-certificate ' . RESPONDJS_DOWNLOAD_URI))) {
    drush_log(dt('The latest respond.js library has been downloaded to @path', array(
      '@path' => $path,
    )), 'success');
    return TRUE;
  }
  else {
    drush_log(dt('Drush was unable to download the respond.js library to @path', array(
      '@path' => $path,
    )), 'error');
    return FALSE;
  }
}