Skip to content

Commit ec42860

Browse files
committed
Also check if sculpin/sculpin is required by composer.json
1 parent 8c5c228 commit ec42860

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

cli/drivers/SculpinValetDriver.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,32 @@ public function serves($sitePath, $siteName, $uri)
1818

1919
private function isModernSculpinProject($sitePath)
2020
{
21-
return is_dir($sitePath.'/source') && is_dir($sitePath.'/output_dev');
21+
return is_dir($sitePath.'/source') &&
22+
is_dir($sitePath.'/output_dev') &&
23+
$this->composerRequiresSculpin($sitePath);
2224
}
2325

2426
private function isLegacySculpinProject($sitePath)
2527
{
2628
return is_dir($sitePath.'/.sculpin');
2729
}
2830

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+
2947
/**
3048
* Mutate the incoming URI.
3149
*

0 commit comments

Comments
 (0)