Skip to content

Commit d636e24

Browse files
BradezExpDev07ExpDev07
authored
[4.x] Fix multiple issues when running on Windows. (#133)
* fix * Remove .idea/ from gitignore * Fixes for running installer on Windows. * Fix tests on Windows. Co-authored-by: ExpDev07 <[email protected]> Co-authored-by: ExpDev <[email protected]>
1 parent 54f3226 commit d636e24

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

.github/workflows/tests.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
- cron: '0 0 * * *'
88

99
jobs:
10-
tests:
10+
linux_tests:
1111

1212
runs-on: ubuntu-latest
1313
strategy:
@@ -34,3 +34,37 @@ jobs:
3434

3535
- name: Execute tests
3636
run: vendor/bin/phpunit --verbose
37+
38+
windows_tests:
39+
40+
runs-on: windows-latest
41+
strategy:
42+
fail-fast: true
43+
matrix:
44+
php: [7.3, 7.4]
45+
46+
name: PHP ${{ matrix.php }} - Windows
47+
48+
steps:
49+
- name: Set git to use LF
50+
run: |
51+
git config --global core.autocrlf false
52+
git config --global core.eol lf
53+
54+
- name: Checkout code
55+
uses: actions/checkout@v2
56+
57+
- name: Setup PHP
58+
uses: shivammathur/setup-php@v2
59+
with:
60+
php-version: ${{ matrix.php }}
61+
extensions: dom, curl, libxml, mbstring, zip
62+
tools: composer:v2
63+
coverage: none
64+
ini-values: memory_limit=512M
65+
66+
- name: Install dependencies
67+
run: composer install --no-interaction --prefer-dist
68+
69+
- name: Execute tests
70+
run: vendor/bin/phpunit --verbose

src/NewCommand.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,18 @@ protected function execute(InputInterface $input, OutputInterface $output)
8383

8484
$commands = [
8585
$composer." create-project laravel/laravel $directory $version --remove-vcs --prefer-dist",
86-
"chmod 644 $directory/artisan",
8786
];
8887

89-
if ($directory != '.') {
90-
array_unshift($commands, "rm -rf $directory");
88+
if ($directory != '.' && $input->getOption('force')) {
89+
if (PHP_OS_FAMILY == 'Windows') {
90+
array_unshift($commands, "rd /s /q \"$directory\"");
91+
} else {
92+
array_unshift($commands, "rm -rf $directory");
93+
}
94+
}
95+
96+
if (PHP_OS_FAMILY != 'Windows') {
97+
$commands[] = "chmod 644 $directory/artisan";
9198
}
9299

93100
if ($this->runCommands($commands, $input, $output)->isSuccessful()) {

tests/NewCommandTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ public function test_it_can_scaffold_a_new_laravel_app()
1414
$scaffoldDirectoryName = 'tests-output/my-app';
1515
$scaffoldDirectory = __DIR__.'/../'.$scaffoldDirectoryName;
1616

17-
exec("rm -rf $scaffoldDirectory");
17+
if (file_exists($scaffoldDirectory)) {
18+
if (PHP_OS_FAMILY == 'Windows') {
19+
exec("rd /s /q \"$scaffoldDirectory\"");
20+
} else {
21+
exec("rm -rf $scaffoldDirectory");
22+
}
23+
}
1824

1925
$app = new Application('Laravel Installer');
2026
$app->add(new NewCommand);

0 commit comments

Comments
 (0)