From a9031e40ebabb92d20a7e3280494dfb8b0eb9329 Mon Sep 17 00:00:00 2001 From: Sebastian Blank Date: Wed, 9 Jun 2021 11:33:44 +0200 Subject: [PATCH] Add "symlink" option for "bin-compat" config (#9959) --- doc/06-config.md | 7 ++++--- res/composer-schema.json | 4 ++-- src/Composer/Command/ConfigCommand.php | 2 +- src/Composer/Installer/BinaryInstaller.php | 2 ++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/doc/06-config.md b/doc/06-config.md index e93a5b2d3..dffff2104 100644 --- a/doc/06-config.md +++ b/doc/06-config.md @@ -253,11 +253,12 @@ Defaults to `false`. Whether to use the Composer cache in read-only mode. ## bin-compat Defaults to `auto`. Determines the compatibility of the binaries to be installed. -If it is `auto` then Composer only installs .bat proxy files when on Windows. If +If it is `auto` then Composer only installs .bat proxy files when on Windows or WSL. If set to `full` then both .bat files for Windows and scripts for Unix-based operating systems will be installed for each binary. This is mainly useful if you -run Composer inside a linux VM but still want the .bat proxies available for use -in the Windows host OS. +run Composer inside a linux VM but still want the `.bat` proxies available for use +in the Windows host OS. If set to `symlink` Composer will always symlink even on +Windows/WSL. ## prepend-autoloader diff --git a/res/composer-schema.json b/res/composer-schema.json index bba26f718..bb86996e7 100644 --- a/res/composer-schema.json +++ b/res/composer-schema.json @@ -251,8 +251,8 @@ "description": "Whether to use the Composer cache in read-only mode." }, "bin-compat": { - "enum": ["auto", "full"], - "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed) and can be \"full\" (compatible with both Windows and Unix-based systems)." + "enum": ["auto", "full", "symlink"], + "description": "The compatibility of the binaries, defaults to \"auto\" (automatically guessed), can be \"full\" (compatible with both Windows and Unix-based systems) and \"symlink\" (symlink also for WSL)." }, "discard-changes": { "type": ["string", "boolean"], diff --git a/src/Composer/Command/ConfigCommand.php b/src/Composer/Command/ConfigCommand.php index 650daa594..39b4604d3 100644 --- a/src/Composer/Command/ConfigCommand.php +++ b/src/Composer/Command/ConfigCommand.php @@ -390,7 +390,7 @@ EOT ), 'bin-compat' => array( function ($val) { - return in_array($val, array('auto', 'full')); + return in_array($val, array('auto', 'full', 'symlink')); }, function ($val) { return $val; diff --git a/src/Composer/Installer/BinaryInstaller.php b/src/Composer/Installer/BinaryInstaller.php index afb1608dc..840e8745d 100644 --- a/src/Composer/Installer/BinaryInstaller.php +++ b/src/Composer/Installer/BinaryInstaller.php @@ -92,6 +92,8 @@ class BinaryInstaller } } elseif ($this->binCompat === "full") { $this->installFullBinaries($binPath, $link, $bin, $package); + } elseif ($this->binCompat === "symlink") { + $this->installSymlinkBinaries($binPath, $link); } Silencer::call('chmod', $link, 0777 & ~umask()); }