diff --git a/src/Differ/PatchDiffer.php b/src/Differ/PatchDiffer.php index 204295e9..21d5ab6b 100644 --- a/src/Differ/PatchDiffer.php +++ b/src/Differ/PatchDiffer.php @@ -7,6 +7,7 @@ use Nette\Utils\Strings; use SebastianBergmann\Diff\Differ; use Symplify\VendorPatches\Exception\ShouldNotHappenException; +use Symplify\VendorPatches\Utils\FileSystemHelper; use Symplify\VendorPatches\ValueObject\OldAndNewFile; /** @@ -50,7 +51,7 @@ public function diff(OldAndNewFile $oldAndNewFile): string private function resolveRelativeFilePath(string $beforeFilePath): string { - $match = Strings::match($beforeFilePath, self::LOCAL_PATH_REGEX); + $match = Strings::match(FileSystemHelper::normalizePath($beforeFilePath), self::LOCAL_PATH_REGEX); if (! isset($match['local_path'])) { throw new ShouldNotHappenException(); diff --git a/src/FileSystem/PathResolver.php b/src/FileSystem/PathResolver.php index 4a202f19..f4de6682 100644 --- a/src/FileSystem/PathResolver.php +++ b/src/FileSystem/PathResolver.php @@ -6,6 +6,7 @@ use Nette\Utils\Strings; use Symplify\VendorPatches\Exception\ShouldNotHappenException; +use Symplify\VendorPatches\Utils\FileSystemHelper; use Webmozart\Assert\Assert; final class PathResolver @@ -18,7 +19,7 @@ final class PathResolver public static function resolveVendorDirectory(string $filePath): string { - $match = Strings::match($filePath, self::VENDOR_PACKAGE_DIRECTORY_REGEX); + $match = Strings::match(FileSystemHelper::normalizePath($filePath), self::VENDOR_PACKAGE_DIRECTORY_REGEX); if (! isset($match['vendor_package_directory'])) { throw new ShouldNotHappenException('Could not resolve vendor package directory'); } diff --git a/src/Utils/FileSystemHelper.php b/src/Utils/FileSystemHelper.php new file mode 100644 index 00000000..9db329c1 --- /dev/null +++ b/src/Utils/FileSystemHelper.php @@ -0,0 +1,16 @@ +createPatchFilePath($oldAndNewFile, __DIR__ . '/Fixture'); - $this->assertSame('patches/some-new-file-php.patch', $pathFilePath); + $this->assertSame('patches/some-new-file-php.patch', FileSystemHelper::normalizePath($pathFilePath)); } }