-
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Classmap nested path duplication #90
Comments
I can't reproduce that on MacOS 10.15 using Bash shell. I presume since you're writing I think the problem is in
So I think change |
I'm not Windows indeed, but that suggestion doesn't fix this. I'm getting:
which is an interesting mix of separators 🌪️ With your change it's:
|
Try replace that whole } else {
$clean = function($path) { return trim( preg_replace('/[\/\\\\]+/', DIRECTORY_SEPARATOR, $path), DIRECTORY_SEPARATOR ); };
$namespacePath = $clean( $package->config->name );
$classmapDirectory = $clean( $this->config->classmap_directory );
$sourceFile = $file->getPathname();
$packageVendorPath = 'vendor' . DIRECTORY_SEPARATOR . $namespacePath;
$mozartClassesPath = $classmapDirectory . DIRECTORY_SEPARATOR . $namespacePath;
$targetFile = str_replace($packageVendorPath, $mozartClassesPath, $sourceFile);
}
$this->filesystem->copy(
str_replace($this->workingDir, '', $file->getPathname()),
str_replace($this->workingDir, '', $targetFile)
); |
Unfortunately that doesn't solve it. I get:
That is with PR #91 applied. (without #91 there is no difference, but since that PR attempts to address the file already exists issue I though to test both versions) the variables in that function evolve like this:
Is there a reason why you didn't apply the clean function to the By the way, as you can see the workingDir is not properly stripped, probably for the same |
I did not apply After posting here, I tidied it up a bit more and posted it in 43 because I think it's the same issue. Now that I look at that code again, every input is run through I think |
Yes, that cleaned up code works nicely indeed, I get the following variable progression: $sourceFilePath = "vendor\iio\libmergepdf\tcpdi\tcpdi.php";
$namespacePath = "iio\libmergepdf";
$classmapDirectory = "lib\classes";
$packageVendorPath = "vendor\iio\libmergepdf";
$mozartClassesPath = "lib\classes\iio\libmergepdf";
$targetFilePath = "lib\classes\iio\libmergepdf\tcpdi\tcpdi.php"; Would be great if you can include this in master! |
When I have time to write some tests around it I'll make a PR. |
Try this:
And if you could run the actual tests on Windows, that'd be great: #103 (comment) |
Unfortunately his throws an error, apparently caused by prefixing the path with a backslash:
|
Damn. Thank you. The opening slash is used on Unix (MacOS for me) to indicate an absolute path. I'll have to spin up a Windows VM and do some reading. Unfortunately it's not imminent – I've only 20 GB free on my laptop! At a glance, a regex ~ |
if there's anything I can test for you, let me know! Line 45 in 832a558
with: $this->workingDir = $workingDir; Works flawlessly, but I don't know if that's an issue on other OSes. |
Source of `$workingDir` is `getcwd()`. Automated tests pass on MacOS. Manual test passes on Windows: coenjacobs#90 (comment)
Great. That works on MacOS too. I've committed the changed to the PR. I'll also take a look at getting a Windows GitHub Actions workflow running the tests. As I realised in the PR's thread, I'll need to update the file paths in the tests before I expect they'll run. |
I'm not sure if this was already reported before because there seem to be a number of issues regarding namespace duplication, but this appears to be different.
config:
results in the following path:
The classes themselves don't seem to be mapped correctly, but in my particular application it seems they are not used.
I saw a similar thing in #89 though I'm not sure it's the same issue/root cause
The text was updated successfully, but these errors were encountered: