Skip to content

Commit 83eae5a

Browse files
authored
Merge pull request #461 from simensen/modern-sculpin-support
Enable support for modern Sculpin projects.
2 parents 5df7ed7 + fb276d6 commit 83eae5a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

cli/drivers/SculpinValetDriver.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,39 @@ class SculpinValetDriver extends BasicValetDriver
1111
* @return bool
1212
*/
1313
public function serves($sitePath, $siteName, $uri)
14+
{
15+
return $this->isModernSculpinProject($sitePath) ||
16+
$this->isLegacySculpinProject($sitePath);
17+
}
18+
19+
private function isModernSculpinProject($sitePath)
20+
{
21+
return is_dir($sitePath.'/source') &&
22+
is_dir($sitePath.'/output_dev') &&
23+
$this->composerRequiresSculpin($sitePath);
24+
}
25+
26+
private function isLegacySculpinProject($sitePath)
1427
{
1528
return is_dir($sitePath.'/.sculpin');
1629
}
1730

31+
private function composerRequiresSculpin($sitePath)
32+
{
33+
if (! file_exists($sitePath.'/composer.json')) {
34+
return false;
35+
}
36+
37+
$composer_json_source = file_get_contents($sitePath.'/composer.json');
38+
$composer_json = json_decode($composer_json_source, true);
39+
40+
if (json_last_error() !== JSON_ERROR_NONE) {
41+
return false;
42+
}
43+
44+
return isset($composer_json['require']['sculpin/sculpin']);
45+
}
46+
1847
/**
1948
* Mutate the incoming URI.
2049
*

0 commit comments

Comments
 (0)