Skip to content

Commit

Permalink
bug symfony#254 Several small unpack fixes (fabpot)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 1.0-dev branch (closes symfony#254).

Discussion
----------

Several small unpack fixes

Commits
-------

aee80d5 made composer req --unpack fails
1d81d8c avoid unneeded code
638b68d made packages required for composer unpack
  • Loading branch information
fabpot committed Dec 27, 2017
2 parents 0fb53be + aee80d5 commit cc4b1ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions src/Command/RequireCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,13 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$packages = $this->resolver->resolve($input->getArgument('packages'), true);

$versionParser = new VersionParser();
$op = new Operation($input->getOption('unpack'), $input->getOption('sort-packages') || $this->getComposer()->getConfig()->get('sort-packages'));
foreach ($versionParser->parseNameVersionPairs($packages) as $package) {
$op->addPackage($package['name'], $package['version'] ?? '', $input->getOption('dev'));
}

if ($packages) {
$versionParser = new VersionParser();
$op = new Operation($input->getOption('unpack'), $input->getOption('sort-packages') || $this->getComposer()->getConfig()->get('sort-packages'));
foreach ($versionParser->parseNameVersionPairs($packages) as $package) {
$op->addPackage($package['name'], $package['version'] ?? '', $input->getOption('dev'));
}

$unpacker = new Unpacker($this->getComposer());
$result = $unpacker->unpack($op);
$io = $this->getIo();
Expand All @@ -56,6 +55,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$input->setArgument('packages', $result->getRequired());
} elseif ($input->getOption('unpack')) {
$this->getIo()->writeError('<error>--unpack is incompatible with the interactive mode.</error>');

return 1;
}

if ($input->hasOption('no-suggest')) {
Expand Down
2 changes: 1 addition & 1 deletion src/Command/UnpackCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function configure()
$this->setName('unpack')
->setDescription('Unpack a Symfony pack.')
->setDefinition(array(
new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::OPTIONAL, 'Installed packages to unpack.'),
new InputArgument('packages', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'Installed packages to unpack.'),
new InputOption('sort-packages', null, InputOption::VALUE_NONE, 'Sorts packages'),
))
;
Expand Down

0 comments on commit cc4b1ba

Please sign in to comment.