Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

2 Issues with rename: must be absolute paths and downloads _always_ have .phar extension #21

Open
RobertKosten opened this issue May 5, 2020 · 0 comments

Comments

@RobertKosten
Copy link

I am using rename, e.g.

"phpcs": {
        "url": "https://github.com/squizlabs/PHP_CodeSniffer/releases/download/3.5.5/phpcs.phar",
        "rename": true
      }

This currently (1.4.1) fails due to two issues:

  1. The composer (1.10.5) tooling for symlinks require absolute paths (this may be a change on their side, I did not investigate). When using rename the $filename is set to a plain name, phpcs in my example, when it should be /some/path/vendor/bin/phpcs.
  2. (After fixing 1) process always downloads files with a .phar extension, so that symlinkOrCopy produces dangling symlinks for my example, e.g. phpcs -> ../tm/tooly-composer-script/bin/phpcs, when the downloaded file is forced to be ../tm/tooly-composer-script/bin/phpcs.phar.

My proposed patch:

diff -Naur tooly-composer-script/src/Script/Processor.php tooly-composer-script-patch/src/Script/Processor.php
--- tooly-composer-script/src/Script/Processor.php	2019-06-24 22:52:52.000000000 +0200
+++ tooly-composer-script-patch/src/Script/Processor.php	2020-05-05 17:38:06.726662222 +0200
@@ -101,10 +101,11 @@
 
         $filename = $tool->getFilename();
         if ($tool->renameToConfigKey()) {
-            $filename = $tool->getName();
+            $filename = dirname($filename) . DIRECTORY_SEPARATOR . $tool->getName();
         }
         $composerDir = $this->configuration->getComposerBinDirectory();
         $composerPath = $composerDir . DIRECTORY_SEPARATOR . basename($filename);
+        $filename = str_replace('.phar', '', $filename) . '.phar';
 
         if (Platform::isWindows()) {
             $this->helper->getFilesystem()->copyFile($filename, $composerPath);
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant