added config option to optimize the autoloader always
parent
b20021cc6a
commit
f67f04adfb
|
@ -180,6 +180,10 @@
|
|||
"type": "string",
|
||||
"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": {
|
||||
"type": "boolean",
|
||||
"description": "If false, the composer autoloader will not be prepended to existing autoloaders, defaults to true."
|
||||
|
|
|
@ -283,6 +283,7 @@ EOT
|
|||
}
|
||||
),
|
||||
'autoloader-suffix' => array('is_string', function ($val) { return $val === 'null' ? null : $val; }),
|
||||
'autoloader-optimize-always' => array($booleanValidator, $booleanNormalizer),
|
||||
'prepend-autoloader' => array($booleanValidator, $booleanNormalizer),
|
||||
);
|
||||
$multiConfigValues = array(
|
||||
|
|
|
@ -41,12 +41,6 @@ EOT
|
|||
|
||||
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();
|
||||
|
||||
$commandEvent = new CommandEvent(PluginEvents::COMMAND, 'dump-autoload', $input, $output);
|
||||
|
@ -57,6 +51,14 @@ EOT
|
|||
$package = $composer->getPackage();
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ class Config
|
|||
'cache-files-maxsize' => '300MiB',
|
||||
'discard-changes' => false,
|
||||
'autoloader-suffix' => null,
|
||||
'autoloader-optimize-always' => false,
|
||||
'prepend-autoloader' => true,
|
||||
'github-domains' => array('github.com'),
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue