浏览代码

Add COMPOSER_DISCARD_CHANGE env var, refs #1188

Jordi Boggiano 12 年之前
父节点
当前提交
894f530898
共有 2 个文件被更改,包括 5 次插入1 次删除
  1. 4 0
      doc/03-cli.md
  2. 1 1
      src/Composer/Config.php

+ 4 - 0
doc/03-cli.md

@@ -431,6 +431,10 @@ configuration in the project's `composer.json` always wins.
 This env var controls the time composer waits for commands (such as git
 This env var controls the time composer waits for commands (such as git
 commands) to finish executing. The default value is 300 seconds (5 minutes).
 commands) to finish executing. The default value is 300 seconds (5 minutes).
 
 
+### COMPOSER_DISCARD_CHANGES
+
+This env var controls the discard-changes [config option](04-schema.md#config).
+
 ### COMPOSER_NO_INTERACTION
 ### COMPOSER_NO_INTERACTION
 
 
 If set to 1, this env var will make composer behave as if you passed the
 If set to 1, this env var will make composer behave as if you passed the

+ 1 - 1
src/Composer/Config.php

@@ -177,7 +177,7 @@ class Config
                 return rtrim($this->process($this->config[$key]), '/\\');
                 return rtrim($this->process($this->config[$key]), '/\\');
 
 
             case 'discard-changes':
             case 'discard-changes':
-                if (!in_array($this->config[$key], array(true, false, 'stash'), true)) {
+                if (!in_array(getenv('COMPOSER_DISCARD_CHANGES') ?: $this->config[$key], array(true, false, 'stash'), true)) {
                     throw new \RuntimeException(
                     throw new \RuntimeException(
                         "Invalid value for 'discard-changes': {$this->config[$key]}"
                         "Invalid value for 'discard-changes': {$this->config[$key]}"
                     );
                     );