Skip to content

Commit 6edc7c5

Browse files
Merge pull request #26 from drupal-composer/curl-download
Fixes drupal-composer/drupal-project #111: Run robo via the RoboRunner
2 parents d3bcfcb + 3eb7f6a commit 6edc7c5

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/Handler.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,12 @@ public function downloadScaffold() {
111111
$dispatcher->dispatch(self::PRE_DRUPAL_SCAFFOLD_CMD);
112112

113113
// Run Robo
114-
static::execute(
114+
$robo = new RoboRunner();
115+
$robo->execute(
115116
[
116-
$this->getRoboExecutable(),
117+
'robo',
117118
'drupal_scaffold:download',
118119
$drupalCorePackage->getPrettyVersion(),
119-
'--load-from',
120-
dirname(__DIR__) . "/scripts",
121120
'--source',
122121
$options['source'],
123122
'--webroot',
Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @file
44
* Contains \RoboFile
55
*/
6+
namespace DrupalComposer\DrupalScaffold;
67

78
use DrupalComposer\DrupalScaffold\Extract;
89

@@ -102,8 +103,30 @@ public function drupal_scaffoldDownload($version = '8', $options = array(
102103
* @param string $target
103104
*/
104105
protected function downloadFile($source, $target) {
105-
$client = new \GuzzleHttp\Client(['base_uri' => dirname($source) . "/"]);
106-
$response = $client->request('GET', basename($source), ['sink' => $target]);
106+
$this->say("Attempt to download $source to $target");
107+
$fp = fopen($target, 'w+');
108+
if (!$fp) {
109+
$this->yell('Could not open target file ' . $target);
110+
return false;
111+
}
112+
$ch = curl_init();
113+
curl_setopt($ch, CURLOPT_URL, $source);
114+
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
115+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
116+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 100);
117+
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
118+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
119+
curl_setopt($ch, CURLOPT_FILE, $fp);
120+
$result = curl_exec($ch);
121+
fclose($fp);
122+
$details = curl_getinfo($ch);
123+
curl_close($ch);
124+
125+
if (!array_key_exists('http_code', $details) || ($details['http_code'] != '200')) {
126+
$this->yell('Could not download ' . $source);
127+
return false;
128+
}
129+
return true;
107130
}
108131

109132
}

0 commit comments

Comments
 (0)