From ebf4cbdc69cc761568b36e5553216313729fefac Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Wed, 24 Nov 2021 05:32:19 -0500 Subject: [PATCH] Add COMPOSER_NO_DEV environment variable to set the --no-dev flag (#10262) --- doc/03-cli.md | 5 +++++ src/Composer/Command/BaseCommand.php | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/doc/03-cli.md b/doc/03-cli.md index 79a8d0b78..2d647b3d3 100644 --- a/doc/03-cli.md +++ b/doc/03-cli.md @@ -1163,3 +1163,8 @@ If set to `1`, outputs information about events being dispatched, which can be useful for plugin authors to identify what is firing when exactly. ← [Libraries](02-libraries.md) | [Schema](04-schema.md) → + +### COMPOSER_NO_DEV + +If set to `1`, it is the equivalent of passing the `--no-dev` arguement to `install` or +`update`. You can override this for a single command by setting `COMPOSER_NO_DEV=0`. diff --git a/src/Composer/Command/BaseCommand.php b/src/Composer/Command/BaseCommand.php index 4561dc2af..0afcc0db1 100644 --- a/src/Composer/Command/BaseCommand.php +++ b/src/Composer/Command/BaseCommand.php @@ -153,6 +153,12 @@ abstract class BaseCommand extends Command $input->setOption('no-progress', true); } + if (true == $input->hasOption('no-dev')) { + if (!$input->getOption('no-dev') && true == Platform::getEnv('COMPOSER_NO_DEV')) { + $input->setOption('no-dev', true); + } + } + parent::initialize($input, $output); }