Преглед изворни кода

Fixed Windows detection based on #4873 and suppressed some console output in removeJunction.

Niels Keurentjes пре 9 година
родитељ
комит
54c079b559
2 измењених фајлова са 7 додато и 6 уклоњено
  1. 3 2
      src/Composer/Downloader/PathDownloader.php
  2. 4 4
      src/Composer/Util/Filesystem.php

+ 3 - 2
src/Composer/Downloader/PathDownloader.php

@@ -13,6 +13,7 @@
 namespace Composer\Downloader;
 
 use Composer\Package\PackageInterface;
+use Composer\Util\Platform;
 use Symfony\Component\Filesystem\Exception\IOException;
 use Symfony\Component\Filesystem\Filesystem;
 
@@ -48,8 +49,8 @@ class PathDownloader extends FileDownloader
         }
 
         try {
-            if (defined('PHP_WINDOWS_VERSION_BUILD')) {
-                // Implement symlinks as junctions on Windows, with magic shell hackery
+            if (Platform::isWindows()) {
+                // Implement symlinks as NTFS junctions on Windows
                 $this->filesystem->junction($realUrl, $path);
                 $this->io->writeError(sprintf('    Junctioned from %s', $url));
 

+ 4 - 4
src/Composer/Util/Filesystem.php

@@ -590,7 +590,7 @@ class Filesystem
      */
     public function junction($target, $junction)
     {
-        if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
+        if (!Platform::isWindows()) {
             throw new \LogicException(sprintf('Function %s is not available on non-Windows platform', __CLASS__));
         }
         if (!is_dir($target)) {
@@ -612,7 +612,7 @@ class Filesystem
      */
     public function isJunction($junction)
     {
-        if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
+        if (!Platform::isWindows()) {
             return false;
         }
         if (!is_dir($junction) || is_link($junction)) {
@@ -631,7 +631,7 @@ class Filesystem
      */
     public function removeJunction($junction)
     {
-        if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
+        if (!Platform::isWindows()) {
             return false;
         }
         $junction = rtrim(str_replace('/', DIRECTORY_SEPARATOR, $junction), DIRECTORY_SEPARATOR);
@@ -639,6 +639,6 @@ class Filesystem
             throw new IOException(sprintf('%s is not a junction and thus cannot be removed as one', $junction));
         }
         $cmd = sprintf('rmdir /S /Q %s', ProcessExecutor::escape($junction));
-        return ($this->getProcess()->execute($cmd) === 0);
+        return ($this->getProcess()->execute($cmd, $output) === 0);
     }
 }