diff --git a/drush/provision_git.drush.inc b/drush/provision_git.drush.inc index 303fe8f..a449c4f 100644 --- a/drush/provision_git.drush.inc +++ b/drush/provision_git.drush.inc @@ -306,6 +306,48 @@ function drush_provision_git_clone($git_url = '', $path = '', $git_ref = '') { // The command failed return drush_set_error('DRUSH_PROVISION_GIT_CLONE_FAILED', dt("Git clone failed! \nThe specific errors are below:\n!errors", array('!errors' => implode("\n", drush_shell_exec_output())))); } + + drush_log('Checking for Composer lock file in repository.'); + chdir($path); + if (file_exists('composer.lock')) { + drush_log('Found Composer lock file. Installing dependencies. This may take awhile.'); + #$command = 'composer install --no-progress --prefer-dist --no-interaction --no-suggest'; + $command = 'COMPOSER_CACHE_DIR=/var/aegir/platform/.composer-cache-dir composer install --no-progress --prefer-dist --no-interaction --no-suggest'; + if (_provision_git_exec($command)) { + drush_log(dt('Installed dependencies.'), 'ok'); + } + else { + return drush_log(dt('Composer install failed to complete without errors! Your platform is likely broken until dependencies are fully installed. Try running the following commands: :composer_install', array(':composer_install' => "cd {$path}; composer install")), 'warning'); + } + } +} + +function _provision_git_exec($command) { + drush_log('Running: ' . $command, 'debug'); + $descriptorspec = array( + 0 => array("pipe", "r"), // stdin + 1 => array("pipe", "w"), // stdout + 2 => array("pipe", "w"), // stderr + ); + $process = proc_open($command, $descriptorspec, $pipes, realpath('./')); + if (is_resource($process)) { + $sockets = array($pipes[1], $pipes[2]); + while (stream_select($sockets, $write = NULL, $except = NULL, $timeout = 300)) { + foreach ($sockets as $socket) { + if (!feof($socket) && $output = fgets($socket)) { + drush_log($output, 'info'); + } + else { + if (proc_close($process)) { + drush_log('Finished running: ' . $command, 'debug'); + } + else { + return drush_log(dt('An error occured when running command!'), 'warning'); + } + } + } + } + } } /**