live_css.drush.inc in Live CSS 7.2
Action for DruSH to take to easily set up Live CSS and download Ace
for the user.
File
drush/live_css.drush.inc
View source
<?php
define('ACE_DOWNLOAD_URI', 'https://github.com/ajaxorg/ace-builds/archive/master.zip');
function live_css_drush_command() {
$items['ace-download'] = array(
'callback' => 'live_css_drush_download',
'description' => dt('Downloads the required ACE library from http://ace.c9.io/.'),
'arguments' => array(
'path' => dt('Optional. The path to the download folder. If omitted, Drush will use the default location (<code>sites/all/libraries/ace</code>).'),
),
);
return $items;
}
function live_css_drush_download() {
$args = func_get_args();
if ($args[0]) {
$path = $args[0];
}
else {
$path = drush_get_context('DRUSH_DRUPAL_ROOT') . '/sites/all/libraries/ace';
}
if (!is_dir($path)) {
drush_op('mkdir', $path);
drush_log(dt('Directory @path was created', array(
'@path' => $path,
)), 'notice');
}
$olddir = getcwd();
chdir($path);
$filepath = drush_download_file(ACE_DOWNLOAD_URI);
if ($filepath) {
$filename = basename($filepath);
if (is_dir('ace-builds-master')) {
drush_delete_dir('ace-builds-master', TRUE);
drush_log(dt('An existing Ace plugin was deleted from @path', array(
'@path' => $path,
)), 'notice');
}
drush_tarball_extract($filename, '../');
drush_move_dir('../ace-builds-master', '../ace', TRUE);
}
if (is_dir('../ace')) {
drush_log(dt('Ace plugin has been installed in @path', array(
'@path' => $path,
)), 'success');
}
else {
drush_log(dt('Drush was unable to install the Ace plugin to @path', array(
'@path' => $path,
)), 'error');
}
chdir($olddir);
}
function drush_live_css_post_enable() {
$modules = func_get_args();
if (in_array('live_css', $modules)) {
live_css_drush_download();
}
}
Functions
Constants
Name |
Description |
ACE_DOWNLOAD_URI |
@file
Action for DruSH to take to easily set up Live CSS and download Ace
for the user. |