diff --git a/doc/03-cli.md b/doc/03-cli.md index 19d26939e..a78c5ed93 100644 --- a/doc/03-cli.md +++ b/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 diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 54d3961ac..1123a6fed 100644 --- a/src/Composer/Config.php +++ b/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]}" );