Parcourir la source

Add COMPOSER_DISCARD_CHANGE env var, refs #1188

Jordi Boggiano il y a 12 ans
Parent
commit
894f530898
2 fichiers modifiés avec 5 ajouts et 1 suppressions
  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
 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
 
 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]), '/\\');
 
             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(
                         "Invalid value for 'discard-changes': {$this->config[$key]}"
                     );