added prefer_dist option to composer plugin

This commit is contained in:
Alexander Pirogov 2013-07-18 16:10:55 +03:00
parent 6c76208992
commit a137e9c0c6

View file

@ -19,6 +19,7 @@ class Composer implements \PHPCI\Plugin
{ {
protected $directory; protected $directory;
protected $action; protected $action;
protected $preferDist;
protected $phpci; protected $phpci;
public function __construct(\PHPCI\Builder $phpci, array $options = array()) public function __construct(\PHPCI\Builder $phpci, array $options = array())
@ -27,6 +28,7 @@ class Composer implements \PHPCI\Plugin
$this->phpci = $phpci; $this->phpci = $phpci;
$this->directory = isset($options['directory']) ? $path . '/' . $options['directory'] : $path; $this->directory = isset($options['directory']) ? $path . '/' . $options['directory'] : $path;
$this->action = isset($options['action']) ? $options['action'] : 'update'; $this->action = isset($options['action']) ? $options['action'] : 'update';
$this->preferDist = isset($options['prefer_dist']) ? $options['prefer_dist'] : true;
} }
/** /**
@ -34,7 +36,7 @@ class Composer implements \PHPCI\Plugin
*/ */
public function execute() public function execute()
{ {
$cmd = PHPCI_DIR . 'composer.phar --prefer-dist --working-dir="%s" %s'; $cmd = PHPCI_DIR . 'composer.phar '. ($this->preferDist ? '--prefer-dist' : null) .' --working-dir="%s" %s';
return $this->phpci->executeCommand($cmd, $this->directory, $this->action); return $this->phpci->executeCommand($cmd, $this->directory, $this->action);
} }
} }