Skip to content

Commit

Permalink
Merge pull request #10 from jedymatt/9-detected-duplicate-mysql-services
Browse files Browse the repository at this point in the history
Detect services with only preceding whitespace and not include any whitespace character
  • Loading branch information
jedymatt authored Sep 25, 2022
2 parents 09d9c3d + ebf4069 commit 101b76a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Console/SailEnvCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected function getServicesFromDockerCompose(): array
$dockerComposeContent = file_get_contents($this->laravel->basePath('docker-compose.yml'));

$regex = '/'.implode('|', array_map(function ($service) {
return '(?<=\s)'.$service.'(?=:)'; // Match service name followed by ':' (e.g. mysql:) and preceded by whitespace
return '(?<=[^\S]\s)'.$service.'(?=:)'; // Match service name followed by ':' (e.g. mysql:) and preceded only by whitespace
}, $this->services)).'/';

preg_match_all($regex, $dockerComposeContent, $matches);
Expand Down

0 comments on commit 101b76a

Please sign in to comment.