Skip to content

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

Description

@RobertKosten

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);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions