1
0
Fork 0

Scratch 'prefer-source'; 'preferred-install' is the bee's knees

pull/1658/head
Miklós Márton 2013-03-05 12:56:09 +01:00
parent 9110c6413e
commit 72a4146383
6 changed files with 52 additions and 13 deletions

View File

@ -581,8 +581,9 @@ The following options are supported:
higher if you have a slow connection or huge vendors.
* **use-include-path:** Defaults to `false`. If true, the Composer autoloader
will also look for classes in the PHP include path.
* **prefer-source:** Defaults to `false`. If true, Composer will always prefer
source installs.
* **preferred-install:** Defaults to `auto` and can be any of `source`, `dist` or
`auto`. This option allows you to set the install method Composer will prefer to
use.
* **github-protocols:** Defaults to `["git", "https", "http"]`. A list of
protocols to use for github.com clones, in priority order. Use this if you are
behind a proxy or have somehow bad performances with the git protocol.

View File

@ -116,9 +116,9 @@
"type": "boolean",
"description": "If true, the Composer autoloader will also look for classes in the PHP include path."
},
"prefer-source": {
"type": "boolean",
"description": "If true, Composer will always prefer source installs."
"preferred-install": {
"type": "string",
"description": "The install method Composer will prefer to use, defaults to auto and can be any of source, dist or auto."
},
"notify-on-install": {
"type": "boolean",

View File

@ -258,9 +258,9 @@ EOT
$booleanValidator,
$booleanNormalizer
),
'prefer-source' => array(
$booleanValidator,
$booleanNormalizer
'preferred-install' => array(
function ($val) { return in_array($val, array('auto', 'source', 'dist'), true); },
function ($val) { return $val; }
),
'notify-on-install' => array(
$booleanValidator,

View File

@ -61,11 +61,30 @@ EOT
$io = $this->getIO();
$install = Installer::create($io, $composer);
$preferSource = false;
$preferDist = false;
switch ($composer->getConfig()->get('preferred-install')) {
case 'source':
$preferSource = true;
break;
case 'dist':
$preferDist = true;
break;
case 'auto':
default:
// noop
break;
}
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist')) {
$preferSource = $input->getOption('prefer-source');
$preferDist = $input->getOption('prefer-dist');
}
$install
->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose'))
->setPreferSource($input->getOption('prefer-source') || $composer->getConfig()->get('prefer-source'))
->setPreferDist($input->getOption('prefer-dist'))
->setPreferSource($preferSource)
->setPreferDist($preferDist)
->setDevMode($input->getOption('dev'))
->setRunScripts(!$input->getOption('no-scripts'))
->setOptimizeAutoloader($input->getOption('optimize-autoloader'))

View File

@ -64,11 +64,30 @@ EOT
$io = $this->getIO();
$install = Installer::create($io, $composer);
$preferSource = false;
$preferDist = false;
switch ($composer->getConfig()->get('preferred-install')) {
case 'source':
$preferSource = true;
break;
case 'dist':
$preferDist = true;
break;
case 'auto':
default:
// noop
break;
}
if ($input->getOption('prefer-source') || $input->getOption('prefer-dist')) {
$preferSource = $input->getOption('prefer-source');
$preferDist = $input->getOption('prefer-dist');
}
$install
->setDryRun($input->getOption('dry-run'))
->setVerbose($input->getOption('verbose'))
->setPreferSource($input->getOption('prefer-source') || $composer->getConfig()->get('prefer-source'))
->setPreferDist($input->getOption('prefer-dist'))
->setPreferSource($preferSource)
->setPreferDist($preferDist)
->setDevMode(!$input->getOption('no-dev'))
->setRunScripts(!$input->getOption('no-scripts'))
->setOptimizeAutoloader($input->getOption('optimize-autoloader'))

View File

@ -22,7 +22,7 @@ class Config
public static $defaultConfig = array(
'process-timeout' => 300,
'use-include-path' => false,
'prefer-source' => false,
'preferred-install' => 'auto',
'notify-on-install' => true,
'github-protocols' => array('git', 'https', 'http'),
'vendor-dir' => 'vendor',