Skip to content

Commit ea4bc71

Browse files
authored
Merge pull request #56 from koossaayy/fix_configuration_for_windows_os
Fix configuration for windows os
2 parents dd61359 + 9ceed7c commit ea4bc71

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

configure.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ function replace_in_file(string $file, array $replacements): void {
6060
);
6161
}
6262

63+
function replaceForWindows(): array {
64+
return preg_split('/\\r\\n|\\r|\\n/', run('dir /S /B * | findstr /v /i .git\ | findstr /v /i vendor | findstr /v /i '.basename(__FILE__).' | findstr /r /i /M /F:/ ":author :vendor :package VendorName skeleton vendor_name vendor_slug [email protected]"'));
65+
}
66+
67+
function replaceForAllOtherOSes(): array {
68+
return explode(PHP_EOL, run('grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|vendor_name|vendor_slug|[email protected]" --exclude-dir=vendor ./* ./.github/* | grep -v ' . basename(__FILE__)));
69+
}
70+
71+
6372
$gitName = run('git config user.name');
6473
$authorName = ask('Author name', $gitName);
6574

@@ -100,7 +109,7 @@ function replace_in_file(string $file, array $replacements): void {
100109
exit(1);
101110
}
102111

103-
$files = explode(PHP_EOL, run('grep -E -r -l -i ":author|:vendor|:package|VendorName|skeleton|vendor_name|vendor_slug|[email protected]" --exclude-dir=vendor ./* ./.github/* | grep -v ' . basename(__FILE__)));
112+
$files = (str_starts_with(strtoupper(PHP_OS), 'WIN') ? replaceForWindows() : replaceForAllOtherOSes());
104113

105114
foreach ($files as $file) {
106115
replace_in_file($file, [
@@ -117,12 +126,10 @@ function replace_in_file(string $file, array $replacements): void {
117126
]);
118127

119128
match (true) {
120-
str_contains($file, 'src/Skeleton.php') => rename($file, './src/' . $className . '.php'),
121-
str_contains($file, 'src/SkeletonServiceProvider.php') => rename($file, './src/' . $className . 'ServiceProvider.php'),
122-
str_contains($file, 'src/SkeletonFacade.php') => rename($file, './src/' . $className . 'Facade.php'),
123-
str_contains($file, 'src/Commands/SkeletonCommand.php') => rename($file, './src/Commands/' . $className . 'Command.php'),
129+
str_contains($file, 'src'.DIRECTORY_SEPARATOR.'SkeletonClass.php') => rename($file, '.'.DIRECTORY_SEPARATOR.'src'.DIRECTORY_SEPARATOR.'' . $className . 'Class.php'),
124130
default => [],
125131
};
132+
126133
}
127134

128135
confirm('Execute `composer install` and run tests?') && run('composer install && composer test');

0 commit comments

Comments
 (0)