Skip to content

Commit

Permalink
Fix: Specify working-dir option when using file argument to update lo…
Browse files Browse the repository at this point in the history
…cker
  • Loading branch information
localheinz committed Dec 24, 2018
1 parent fd6ea59 commit adc9050
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/Command/NormalizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,15 @@ protected function execute(Console\Input\InputInterface $input, Console\Output\O

$this->resetComposer();

$file = $input->getArgument('file');

if (\is_string($file)) {
return $this->updateLockerInWorkingDirectory(
$output,
\dirname($file)
);
}

return $this->updateLocker($output);
}

Expand Down Expand Up @@ -382,4 +391,30 @@ private function updateLocker(Console\Output\OutputInterface $output): int
$output
);
}

/**
* @see https://getcomposer.org/doc/03-cli.md#update
*
* @param Console\Output\OutputInterface $output
* @param string $workingDirectory
*
* @throws \Exception
*
* @return int
*/
private function updateLockerInWorkingDirectory(Console\Output\OutputInterface $output, string $workingDirectory): int
{
return $this->getApplication()->run(
new Console\Input\ArrayInput([
'command' => 'update',
'--lock' => true,
'--no-autoloader' => true,
'--no-plugins' => true,
'--no-scripts' => true,
'--no-suggest' => true,
'--working-dir' => $workingDirectory,
]),
$output
);
}
}

0 comments on commit adc9050

Please sign in to comment.