function drush_css3pie_download in css3pie 7.2
Drush command callback to download the Secureshare plugin.
1 call to drush_css3pie_download()
- drush_css3pie_post_pm_enable in ./
css3pie.drush.inc - Implements drush_MODULE_post_COMMAND().
File
- ./
css3pie.drush.inc, line 50 - css3pie drush integration for lib downloading
Code
function drush_css3pie_download() {
if (!drush_shell_exec('type unzip')) {
return drush_set_error(dt('Missing dependency: unzip. Install it before using this command.'));
}
$args = func_get_args();
if (!empty($args[0])) {
$path = $args[0];
}
else {
$path = CSS3PIE_DEFAULT_DESTINATION;
}
// Create the path if it does not exist.
if (!is_dir($path)) {
drush_op('mkdir', $path);
drush_log(dt('Directory @path was created', array(
'@path' => $path,
)), 'notice');
}
// Set the directory to the download location.
$olddir = getcwd();
chdir($path);
$filename = basename(CSS3PIE_DOWNLOAD_URI);
// Remove any existing plugin directory
if (is_dir(CSS3PIE_DEFAULT_DESTINATION_PATH)) {
drush_log(dt('A existing download was overwritten at @path', array(
'@path' => $path,
)), 'notice');
}
else {
drush_op('mkdir', CSS3PIE_DEFAULT_DESTINATION_PATH);
drush_log(dt('Directory @path was created', array(
'@path' => $path,
)), 'notice');
}
chdir(CSS3PIE_DEFAULT_DESTINATION_PATH);
// Remove any existing plugin zip archive
if (is_file($filename)) {
drush_op('unlink', $filename);
}
// Download the zip archive
if (!drush_shell_exec('wget ' . CSS3PIE_DOWNLOAD_URI)) {
drush_shell_exec('curl -O ' . CSS3PIE_DOWNLOAD_URI);
}
if (is_file($filename)) {
// Decompress the zip archive
drush_shell_exec('unzip -qq -o ' . $filename);
// Remove the zip archive
drush_op('unlink', $filename);
}
// Set working directory back to the previous working directory.
chdir($olddir);
if (is_dir($path . '/' . CSS3PIE_DEFAULT_DESTINATION_PATH)) {
drush_log(dt('css3pie library has been downloaded to @path', array(
'@path' => $path,
)), 'success');
}
else {
drush_log(dt('Drush was unable to download the css3pie library to @path', array(
'@path' => $path,
)), 'error');
}
}