1
0
Fork 0

added config option to optimize the autoloader always

pull/2605/head
Robert Boloc 2014-01-16 20:44:16 +01:00
parent b20021cc6a
commit f67f04adfb
4 changed files with 15 additions and 7 deletions

View File

@ -180,6 +180,10 @@
"type": "string", "type": "string",
"description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated." "description": "Optional string to be used as a suffix for the generated Composer autoloader. When null a random one will be generated."
}, },
"autoloader-optimize-always": {
"type": "boolean",
"description": "Always optimize when dumping the autoloader"
},
"prepend-autoloader": { "prepend-autoloader": {
"type": "boolean", "type": "boolean",
"description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true." "description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."

View File

@ -283,6 +283,7 @@ EOT
} }
), ),
'autoloader-suffix' => array('is_string', function ($val) { return $val === 'null' ? null : $val; }), 'autoloader-suffix' => array('is_string', function ($val) { return $val === 'null' ? null : $val; }),
'autoloader-optimize-always' => array($booleanValidator, $booleanNormalizer),
'prepend-autoloader' => array($booleanValidator, $booleanNormalizer), 'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
); );
$multiConfigValues = array( $multiConfigValues = array(

View File

@ -41,12 +41,6 @@ EOT
protected function execute(InputInterface $input, OutputInterface $output) protected function execute(InputInterface $input, OutputInterface $output)
{ {
if ($input->getOption('optimize')) {
$output->writeln('<info>Generating optimized autoload files</info>');
} else {
$output->writeln('<info>Generating autoload files</info>');
}
$composer = $this->getComposer(); $composer = $this->getComposer();
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output); $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
@ -57,6 +51,14 @@ EOT
$package = $composer->getPackage(); $package = $composer->getPackage();
$config = $composer->getConfig(); $config = $composer->getConfig();
$composer->getAutoloadGenerator()->dump($config, $localRepo, $package, $installationManager, 'composer', $input->getOption('optimize')); $optimize = $input->getOption('optimize') || $config->get('autoloader-optimize-always');
if ($optimize) {
$output->writeln('<info>Generating optimized autoload files</info>');
} else {
$output->writeln('<info>Generating autoload files</info>');
}
$composer->getAutoloadGenerator()->dump($config, $localRepo, $package, $installationManager, 'composer', $optimize);
} }
} }

View File

@ -36,6 +36,7 @@ class Config
'cache-files-maxsize' => '300MiB', 'cache-files-maxsize' => '300MiB',
'discard-changes' => false, 'discard-changes' => false,
'autoloader-suffix' => null, 'autoloader-suffix' => null,
'autoloader-optimize-always' => false,
'prepend-autoloader' => true, 'prepend-autoloader' => true,
'github-domains' => array('github.com'), 'github-domains' => array('github.com'),
); );