Browse Source

Merge remote-tracking branch 'Dzhuneyt/6650-disable-cache-argument'

Jordi Boggiano 6 years ago
parent
commit
61bd9f83f1
2 changed files with 28 additions and 0 deletions
  1. 14 0
      src/Composer/Command/InstallCommand.php
  2. 14 0
      src/Composer/Command/UpdateCommand.php

+ 14 - 0
src/Composer/Command/InstallCommand.php

@@ -15,6 +15,7 @@ namespace Composer\Command;
 use Composer\Installer;
 use Composer\Plugin\CommandEvent;
 use Composer\Plugin\PluginEvents;
+use Composer\Util\Platform;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Input\InputArgument;
@@ -40,6 +41,7 @@ class InstallCommand extends BaseCommand
                 new InputOption('dry-run', null, InputOption::VALUE_NONE, 'Outputs the operations but will not execute anything (implicitly enables --verbose).'),
                 new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
                 new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
+                new InputOption('no-cache', null, InputOption::VALUE_NONE, 'Do not use the cache directory'),
                 new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
                 new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
                 new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
@@ -93,6 +95,18 @@ EOT
         $install = Installer::create($io, $composer);
 
         $config = $composer->getConfig();
+
+        if ($input->getOption('no-cache')) {
+            $io->write('Skipping cache directory');
+            $config->merge(
+                array(
+                    'config' => array(
+                        'cache-dir' => Platform::isWindows() ? 'nul' : '/dev/null',
+                    )
+                )
+            );
+        }
+
         list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
 
         $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');

+ 14 - 0
src/Composer/Command/UpdateCommand.php

@@ -17,6 +17,7 @@ use Composer\Installer;
 use Composer\IO\IOInterface;
 use Composer\Plugin\CommandEvent;
 use Composer\Plugin\PluginEvents;
+use Composer\Util\Platform;
 use Symfony\Component\Console\Helper\Table;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Input\InputOption;
@@ -44,6 +45,7 @@ class UpdateCommand extends BaseCommand
                 new InputOption('dev', null, InputOption::VALUE_NONE, 'Enables installation of require-dev packages (enabled by default, only present for BC).'),
                 new InputOption('no-dev', null, InputOption::VALUE_NONE, 'Disables installation of require-dev packages.'),
                 new InputOption('lock', null, InputOption::VALUE_NONE, 'Only updates the lock file hash to suppress warning about the lock file being out of date.'),
+                new InputOption('no-cache', null, InputOption::VALUE_NONE, 'Do not use the cache directory'),
                 new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'DEPRECATED: Use no-plugins instead.'),
                 new InputOption('no-autoloader', null, InputOption::VALUE_NONE, 'Skips autoloader generation'),
                 new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Skips the execution of all scripts defined in composer.json file.'),
@@ -128,6 +130,18 @@ EOT
         $install = Installer::create($io, $composer);
 
         $config = $composer->getConfig();
+
+        if ($input->getOption('no-cache')) {
+            $io->write('Skipping cache directory');
+            $config->merge(
+                array(
+                    'config' => array(
+                        'cache-dir' => Platform::isWindows() ? 'nul' : '/dev/null',
+                    )
+                )
+            );
+        }
+
         list($preferSource, $preferDist) = $this->getPreferredInstallOptions($config, $input);
 
         $optimize = $input->getOption('optimize-autoloader') || $config->get('optimize-autoloader');