File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff 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 *
You can’t perform that action at this time.
0 commit comments