소스 검색

Add COMPOSER_ROOT_VERSION env var to override the root version

Jordi Boggiano 13 년 전
부모
커밋
5498b8d6a0
2개의 변경된 파일10개의 추가작업 그리고 0개의 파일을 삭제
  1. 5 0
      doc/03-cli.md
  2. 5 0
      src/Composer/Package/Loader/RootPackageLoader.php

+ 5 - 0
doc/03-cli.md

@@ -189,6 +189,11 @@ For example:
 
     $ COMPOSER=composer-other.json php composer.phar install
 
+### COMPOSER_ROOT_VERSION
+
+By setting this var you can specify the version of the root package, if it can
+not be guessed from VCS info and is not present in `composer.json`.
+
 ### COMPOSER_VENDOR_DIR
 
 By setting this var you can make composer install the dependencies into a

+ 5 - 0
src/Composer/Package/Loader/RootPackageLoader.php

@@ -53,6 +53,11 @@ class RootPackageLoader extends ArrayLoader
                 }
             }
 
+            // override with env var if available
+            if (getenv('COMPOSER_ROOT_VERSION')) {
+                $version = getenv('COMPOSER_ROOT_VERSION');
+            }
+
             $config['version'] = $version;
         } else {
             $version = $config['version'];