Skip to content

Commit

Permalink
Merge pull request #238 from ruudk/is-dir
Browse files Browse the repository at this point in the history
Fix passing configure options without being a real file
  • Loading branch information
mlocati authored Aug 19, 2021
2 parents 97104d5 + bfd8a64 commit f2a8ad7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/Base/Abstracts/Console/Command/BuildCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,20 @@ protected function buildOptions(Package $package, InputInterface $input, OutputI
{
$helper = $this->getHelperSet()->get('question');

$force_opts = $input->getOption('with-configure-options');
$configureOptions = $input->getOption('with-configure-options');

if ($force_opts) {
if (!file_exists($force_opts) || !(is_file($force_opts) || is_link($force_opts)) || !is_readable($force_opts)) {
throw new Exception("File '{$force_opts}' is unusable");
if ($configureOptions) {
if (!file_exists($configureOptions) || is_dir($configureOptions) || !is_readable($configureOptions)) {
throw new Exception("File '{$configureOptions}' is unusable");
}

if (DIRECTORY_SEPARATOR !== '\\' && preg_match('_^/dev/fd/\d+$_', $force_opts)) {
if (DIRECTORY_SEPARATOR !== '\\' && preg_match('_^/dev/fd/\d+$_', $configureOptions)) {
// https://bugs.php.net/bug.php?id=53465
$force_opts = str_replace('/dev/', 'php://', $force_opts);
$configureOptions = str_replace('/dev/', 'php://', $configureOptions);
}
$force_opts = preg_replace(',\\s+,', ' ', file_get_contents($force_opts));
$configureOptions = preg_replace(',\\s+,', ' ', file_get_contents($configureOptions));

return [null, $force_opts];
return [null, $configureOptions];
}

$options = $package->getConfigureOptions();
Expand Down

0 comments on commit f2a8ad7

Please sign in to comment.