From 927959674a303de516db6e775cd65b95bb2828b8 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Tue, 17 Sep 2024 14:34:09 +0100 Subject: [PATCH] Generator::checkOverwrite() - Clearer messaging when overwrite skipped (non-forced) --- src/CRM/CivixBundle/Generator.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/CRM/CivixBundle/Generator.php b/src/CRM/CivixBundle/Generator.php index ed9235e5..7a7e6af2 100644 --- a/src/CRM/CivixBundle/Generator.php +++ b/src/CRM/CivixBundle/Generator.php @@ -822,11 +822,18 @@ public function checkOverwrite($path, $mode): string { return 'write'; } + if ($mode === 'ask' && !$this->input->isInteractive()) { + $mode = 'if-forced'; + } + if ($mode === 'if-forced') { + $mode = $this->input->hasOption('force') && $this->input->getOption('force') ? 'overwrite' : 'keep'; + } + if ($mode === 'overwrite' || $mode === TRUE) { return 'write'; } if ($mode === 'keep'|| $mode === FALSE) { - $this->io->warning("Skip $file: file already exists"); + $this->io->writeln("Skip " . Files::relativize($file) . ": file already exists"); return 'keep'; } if ($mode === 'abort') { @@ -849,12 +856,6 @@ public function checkOverwrite($path, $mode): string { throw new \RuntimeException("File $relPath already exists. Operation aborted"); } } - if ($mode === 'ask' || $mode === 'if-forced') { - if ($this->input->hasOption('force') && $this->input->getOption('force')) { - $this->io->note("Overwrite $file in --force mode"); - return 'write'; - } - } throw new \RuntimeException("Invalid argument checkOverwrite(...$mode)"); }