Skip to content

Commit 47dc263

Browse files
committed
fix configuration.php for Windows OS
1 parent dd61359 commit 47dc263

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

configure.php

Lines changed: 14 additions & 2 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, [
@@ -119,10 +128,13 @@ function replace_in_file(string $file, array $replacements): void {
119128
match (true) {
120129
str_contains($file, 'src/Skeleton.php') => rename($file, './src/' . $className . '.php'),
121130
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'),
131+
str_contains($file, 'src/Facades/Skeleton.php') => rename($file, './src/Facades/' . $className . '.php'),
123132
str_contains($file, 'src/Commands/SkeletonCommand.php') => rename($file, './src/Commands/' . $className . 'Command.php'),
133+
str_contains($file, 'database/migrations/create_skeleton_table.php.stub') => rename($file, './database/migrations/create_' . $packageSlugWithoutPrefix . '_table.php.stub'),
134+
str_contains($file, 'config/skeleton.php') => rename($file, './config/' . $packageSlugWithoutPrefix . '.php'),
124135
default => [],
125136
};
137+
126138
}
127139

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

0 commit comments

Comments
 (0)