From f5422a441d706f46979c5278b6a8ffddbea95b08 Mon Sep 17 00:00:00 2001 From: Niels Keurentjes Date: Tue, 12 Apr 2016 23:51:28 +0200 Subject: [PATCH] Fixed Windows path separators and updated docs. --- doc/05-repositories.md | 12 +++++++----- src/Composer/Util/Platform.php | 2 +- tests/Composer/Test/Util/PlatformTest.php | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/05-repositories.md b/doc/05-repositories.md index a395f2b4a..9887fd9fc 100644 --- a/doc/05-repositories.md +++ b/doc/05-repositories.md @@ -649,8 +649,8 @@ the console will read `Symlinked from ../../packages/my-package`. If symlinking is _not_ possible the package will be copied. In that case, the console will output `Mirrored from ../../packages/my-package`. -Instead of default fallback strategy you can force to use symlink with `"symlink": true` or -mirroring with `"symlink": false` option. +Instead of default fallback strategy you can force to use symlink with `"symlink": true` +or mirroring with `"symlink": false` option. Forcing mirroring can be useful when deploying or generating package from a monolithic repository. ```json @@ -667,9 +667,11 @@ Forcing mirroring can be useful when deploying or generating package from a mono } ``` -If present on *nix systems leading tildes are expanded to the current user's home folder, which -can be handy when working on teams on the same packages. For example `~/git/mypackage` will -automatically load the mypackage clone from `/home//git/mypackage` for every developer. +Leading tildes are expanded to the current user's home folder, and environment +variables are parsed according to host platform. For example `~/git/mypackage` +will automatically load the mypackage clone from `/home//git/mypackage`, +which is equivalent to `$HOME/git/mypackage` on Linux/Mac or +`%USERPROFILE%/git/mypackage` on Windows. > **Note:** Repository paths can also contain wildcards like ``*`` and ``?``. > For details, see the [PHP glob function](http://php.net/glob). diff --git a/src/Composer/Util/Platform.php b/src/Composer/Util/Platform.php index 530591064..ada67c635 100644 --- a/src/Composer/Util/Platform.php +++ b/src/Composer/Util/Platform.php @@ -31,7 +31,7 @@ class Platform return self::getUserDirectory() . substr($path, 1); } return preg_replace_callback(self::isWindows() ? '#^(%(\\w+)%)[/\\\\]#' : '#^(\\$(\\w+))/#', function($matches) { - return getenv($matches[2]) . DIRECTORY_SEPARATOR; + return getenv($matches[2]) . '/'; }, $path); } diff --git a/tests/Composer/Test/Util/PlatformTest.php b/tests/Composer/Test/Util/PlatformTest.php index 4b0491147..985e25cd1 100644 --- a/tests/Composer/Test/Util/PlatformTest.php +++ b/tests/Composer/Test/Util/PlatformTest.php @@ -29,7 +29,7 @@ class PlatformTest extends \PHPUnit_Framework_TestCase } else { $this->assertEquals('/home/test/myPath', Platform::expandPath('$TESTENV/myPath')); } - $this->assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . DIRECTORY_SEPARATOR . 'test', Platform::expandPath('~/test')); + $this->assertEquals((getenv('HOME') ?: getenv('USERPROFILE')) . '/test', Platform::expandPath('~/test')); } public function testIsWindows()