kraken.drush.inc in Kraken 7.2
drush integration for kraken.
File
drush/kraken.drush.inc
View source
<?php
define('KRAKEN_DOWNLOAD_URI', 'https://github.com/kraken-io/kraken-php/archive/master.zip');
function kraken_drush_command() {
$items = array();
$items['kraken-library'] = array(
'callback' => 'drush_kraken_library',
'description' => dt('Download and install the kraken-php library.'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUSH,
'arguments' => array(
'path' => dt('Optional. A path where to install the kraken-php library. If
omitted Drush will use the default location.'),
),
'aliases' => array(
'kraken',
),
);
return $items;
}
function kraken_drush_help($section) {
switch ($section) {
case 'drush:kraken-library':
return dt('Download and install the kraken library. The default location
is sites/all/libraries.');
}
}
function drush_kraken_library() {
$args = func_get_args();
if (!empty($args[0])) {
$path = $args[0];
}
else {
$path = 'sites/all/libraries';
}
if (!is_dir($path)) {
drush_op('mkdir', $path);
drush_log(dt('Directory @path was created', array(
'@path' => $path,
)), 'notice');
}
$olddir = getcwd();
chdir($path);
if ($filepath = drush_download_file(KRAKEN_DOWNLOAD_URI)) {
$filename = basename($filepath);
$dirname = 'kraken-php-master';
if (is_dir($dirname) || is_dir('kraken-php')) {
drush_delete_dir($dirname, TRUE);
drush_delete_dir('kraken-php', TRUE);
drush_log(dt('An existing kraken library was deleted from @path', array(
'@path' => $path,
)), 'notice');
}
drush_tarball_extract($filename);
if ($dirname != 'kraken-php') {
drush_move_dir($dirname, 'kraken-php', TRUE);
$dirname = 'kraken-php';
}
}
if (is_dir($dirname)) {
drush_log(dt('kraken library has been installed in @path', array(
'@path' => $path,
)), 'success');
}
else {
drush_log(dt('Drush was unable to install the kraken library to @path', array(
'@path' => $path,
)), 'error');
}
chdir($olddir);
}