1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-05 08:30:07 +01:00

Merge pull request #461 from simensen/modern-sculpin-support

Enable support for modern Sculpin projects.
This commit is contained in:
Adam Wathan
2018-01-09 09:08:08 -05:00
committed by GitHub

View File

@@ -11,10 +11,39 @@ class SculpinValetDriver extends BasicValetDriver
* @return bool
*/
public function serves($sitePath, $siteName, $uri)
{
return $this->isModernSculpinProject($sitePath) ||
$this->isLegacySculpinProject($sitePath);
}
private function isModernSculpinProject($sitePath)
{
return is_dir($sitePath.'/source') &&
is_dir($sitePath.'/output_dev') &&
$this->composerRequiresSculpin($sitePath);
}
private function isLegacySculpinProject($sitePath)
{
return is_dir($sitePath.'/.sculpin');
}
private function composerRequiresSculpin($sitePath)
{
if (! file_exists($sitePath.'/composer.json')) {
return false;
}
$composer_json_source = file_get_contents($sitePath.'/composer.json');
$composer_json = json_decode($composer_json_source, true);
if (json_last_error() !== JSON_ERROR_NONE) {
return false;
}
return isset($composer_json['require']['sculpin/sculpin']);
}
/**
* Mutate the incoming URI.
*