Skip to content

Commit 3c2f812

Browse files
committed
Merge pull request #12 from aleksip/fix-fetchstarterkit
Fix fetchStarterKit directory issue
2 parents 725f373 + d383378 commit 3c2f812

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/PatternLab/Fetch.php

+11-7
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,16 @@ public function fetchStarterKit($starterkit = "") {
5454
if (empty($starterkit)) {
5555
Console::writeError("please provide a path for the starterkit before trying to fetch it...");
5656
}
57-
57+
58+
// figure out the options for the GH path
59+
list($org,$repo,$tag) = $this->getPackageInfo($starterkit);
60+
5861
// set default attributes
5962
$sourceDir = Config::getOption("sourceDir");
6063
$tempDir = sys_get_temp_dir().DIRECTORY_SEPARATOR."pl-sk";
6164
$tempDirSK = $tempDir.DIRECTORY_SEPARATOR."pl-sk-archive";
62-
$tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR."dist";
63-
$tempComposerFile = $tempDirSK.DIRECTORY_SEPARATOR."composer.json";
64-
65-
// figure out the options for the GH path
66-
list($org,$repo,$tag) = $this->getPackageInfo($starterkit);
65+
$tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR.$repo."-".$tag.DIRECTORY_SEPARATOR."dist";
66+
$tempComposerFile = $tempDirSK.DIRECTORY_SEPARATOR.$repo."-".$tag.DIRECTORY_SEPARATOR."composer.json";
6767

6868
//get the path to the GH repo and validate it
6969
$tarballUrl = "https://github.com/".$org."/".$repo."/archive/".$tag.".tar.gz";
@@ -99,7 +99,11 @@ public function fetchStarterKit($starterkit = "") {
9999
$zippy = Zippy::load();
100100
$zippy->addStrategy(new UnpackFileStrategy());
101101
$zippy->getAdapterFor('tar.gz')->open($tempFile)->extract($tempDirSK);
102-
102+
103+
if (!is_dir($tempDirDist)) {
104+
// try without repo dir
105+
$tempDirDist = $tempDirSK.DIRECTORY_SEPARATOR."dist";
106+
}
103107
// thrown an error if temp/dist/ doesn't exist
104108
if (!is_dir($tempDirDist)) {
105109
Console::writeError("the starterkit needs to contain a dist/ directory before it can be installed...");

0 commit comments

Comments
 (0)