Skip to content

Commit

Permalink
#3228: command requires target file to exist before merge (#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
isramv authored and jmolivas committed May 7, 2017
1 parent feeac74 commit 64c4f8d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Command/Yaml/MergeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Component\Console\Command\Command;
use Drupal\Console\Core\Command\Shared\CommandTrait;
use Drupal\Console\Core\Style\DrupalStyle;
use Symfony\Component\Filesystem\Filesystem;

class MergeCommand extends Command
{
Expand Down Expand Up @@ -48,6 +49,24 @@ protected function execute(InputInterface $input, OutputInterface $output)
$yaml_destination = realpath($input->getArgument('yaml-destination'));
$yaml_files = $input->getArgument('yaml-files');

if(!$yaml_destination) {
$fs = new Filesystem();
try {
$fs->touch($input->getArgument('yaml-destination'));
$yaml_destination = realpath($input->getArgument('yaml-destination'));
} catch (\Exception $e) {
$io->error(
sprintf(
'%s: %s',
$this->trans('commands.yaml.merge.messages.error-writing'),
$e->getMessage()
)
);

return;
}
}

if (count($yaml_files) < 2) {
$io->error($this->trans('commands.yaml.merge.messages.two-files-required'));

Expand Down

0 comments on commit 64c4f8d

Please sign in to comment.