File tree Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Expand file tree Collapse file tree 2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change 3838 "prefer-stable" : true ,
3939 "require" : {
4040 "php" : " ^7.3|^8.0" ,
41- "symfony/yaml" : " ^6.0" ,
4241 "laravel/sail" : " ^1.0"
4342 },
4443 "require-dev" : {
4544 "laravel/pint" : " ^1.0"
46- },
47- "scripts" : {
48- "lint" : " vendor/bin/pint"
4945 }
5046}
Original file line number Diff line number Diff line change 33namespace Jedymatt \LaravelSailEnv \Console ;
44
55use Laravel \Sail \Console \InstallCommand ;
6- use Symfony \Component \Yaml \Yaml ;
76
87class SailEnvCommand extends InstallCommand
98{
@@ -68,12 +67,14 @@ public function handle()
6867
6968 protected function servicesFromDockerCompose (): array
7069 {
71- $ dockerCompose = Yaml:: parseFile ($ this ->laravel ->basePath ('docker-compose.yml ' ));
70+ $ environment = file_get_contents ($ this ->laravel ->basePath ('docker-compose.yml ' ));
7271
73- $ sailServices = array_filter ( $ dockerCompose [ ' services ' ], function ($ service ) {
74- return in_array ( $ service, $ this -> services );
75- }, ARRAY_FILTER_USE_KEY ) ;
72+ $ regex = ' / ' . implode ( ' | ' , array_map ( function ($ service ) {
73+ return ' (?<=\s) ' . $ service. ' (?=:) ' ; // Match service name followed by ':' (e.g. mysql:) and preceded by whitespace
74+ }, $ this -> services )). ' / ' ;
7675
77- return array_keys ($ sailServices );
76+ preg_match_all ($ regex , $ environment , $ matches );
77+
78+ return array_values ($ matches [0 ]);
7879 }
7980}
You can’t perform that action at this time.
0 commit comments