Skip to content

Commit

Permalink
Merge pull request #140 from spiral/bugfix/paths-on-windows
Browse files Browse the repository at this point in the history
Fix method normalizePath for Windows
  • Loading branch information
msmakouz committed Nov 15, 2023
2 parents 472836b + 76c3e41 commit 0f638c0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
6 changes: 4 additions & 2 deletions installer/Internal/Events/CopyEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ public function normalizePath(string $root, string $path): string
$source = \ltrim($path, '/');

if ($sourceRoot === '') {
return '/' . $source;
return \file_exists($source) ? $source : '/' . $source;
}

return '/' . $sourceRoot . '/' . $source;
return \file_exists($sourceRoot . '/' . $source)
? $sourceRoot . '/' . $source
: '/' . $sourceRoot . '/' . $source;
}

public function detectType(string $path): string
Expand Down
2 changes: 1 addition & 1 deletion installer/Tests/InstallationResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public function assertCopied(string $path, string $destination): self
{
foreach ($this->events as $event) {
if ($event instanceof CopyEvent) {
if (\str_ends_with($event->getFullSource(), $path)) {
if (\str_ends_with(\str_replace('\\', '/', $event->getFullSource()), \str_replace('\\', '/', $path))) {
if (\str_ends_with($event->getFullDestination(), $destination)) {
Assert::assertTrue(true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Tests\Unit\Internal\Generator\Bootloader;

use Installer\Internal\Generator\Bootloader\ClassBinding;
use Nette\PhpGenerator\Printer;
use Spiral\Reactor\Partial\PhpNamespace;
use Tests\TestCase;

Expand All @@ -22,6 +23,9 @@ public function testRender(): void
$binding->render($namespace = new PhpNamespace('App'))
);

$printer = new Printer();
$printer->omitEmptyNamespaces = false;

$this->assertSame(
<<<PHP
namespace App;
Expand All @@ -30,7 +34,7 @@ public function testRender(): void
PHP,
(string)$namespace
$printer->printNamespace($namespace->getElement())
);
}
}
2 changes: 1 addition & 1 deletion installer/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"license": "MIT",
"description": "Spiral Application installer",
"require-dev": {
"nette/php-generator": "^4.0",
"nette/php-generator": "^4.1.2",
"spiral/framework": "^3.8",
"spiral/nyholm-bridge": "^1.0",
"composer/composer": "^2.4",
Expand Down

0 comments on commit 0f638c0

Please sign in to comment.