Yaffs site version 1.1
[yaffs-website] / vendor / drupal / console-core / src / Command / Yaml / MergeCommand.php
index 082509260da58d6caba8ab8d0b8baf467bec671a..da655a769111f9b859b6d4c3530ff58340de1178 100644 (file)
@@ -15,6 +15,7 @@ use Symfony\Component\Yaml\Parser;
 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
 {
@@ -44,10 +45,28 @@ class MergeCommand extends Command
         $yaml = new Parser();
         $dumper = new Dumper();
 
-        $final_yaml = array();
+        $final_yaml = [];
         $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'));
 
@@ -155,7 +174,7 @@ class MergeCommand extends Command
 
         $yaml_files = $input->getArgument('yaml-files');
         if (!$yaml_files) {
-            $yaml_files = array();
+            $yaml_files = [];
 
             while (true) {
                 // Set the string key based on among files provided