|
16 | 16 | use Symfony\Component\Console\Input\InputOption; |
17 | 17 | use Symfony\Component\Console\Output\OutputInterface; |
18 | 18 |
|
| 19 | +use function Laravel\Prompts\confirm; |
19 | 20 | use function Laravel\Prompts\search; |
20 | 21 |
|
21 | 22 | class CopyFromVendorCommand extends AbstractCommand |
@@ -164,12 +165,32 @@ private function confirmCopy(string $sourceFile, string $absoluteDestPath, strin |
164 | 165 | ]); |
165 | 166 | $this->io->newLine(); |
166 | 167 |
|
167 | | - if (file_exists($absoluteDestPath)) { |
168 | | - $this->io->warning("File already exists at destination!"); |
169 | | - return $this->io->confirm('Overwrite existing file?', false); |
170 | | - } |
| 168 | + $this->setPromptEnvironment(); |
| 169 | + |
| 170 | + try { |
| 171 | + if (file_exists($absoluteDestPath)) { |
| 172 | + $this->io->warning("File already exists at destination!"); |
| 173 | + $result = confirm( |
| 174 | + label: 'Overwrite existing file?', |
| 175 | + default: false |
| 176 | + ); |
| 177 | + \Laravel\Prompts\Prompt::terminal()->restoreTty(); |
| 178 | + $this->resetPromptEnvironment(); |
| 179 | + return $result; |
| 180 | + } |
171 | 181 |
|
172 | | - return $this->io->confirm('Proceed with copy?', true); |
| 182 | + $result = confirm( |
| 183 | + label: 'Proceed with copy?', |
| 184 | + default: true |
| 185 | + ); |
| 186 | + \Laravel\Prompts\Prompt::terminal()->restoreTty(); |
| 187 | + $this->resetPromptEnvironment(); |
| 188 | + return $result; |
| 189 | + } catch (\Exception $e) { |
| 190 | + $this->resetPromptEnvironment(); |
| 191 | + $this->io->error('Interactive mode failed: ' . $e->getMessage()); |
| 192 | + return false; |
| 193 | + } |
173 | 194 | } |
174 | 195 |
|
175 | 196 | private function performCopy(string $absoluteSourcePath, string $absoluteDestPath): void |
@@ -208,10 +229,6 @@ private function showDryRunPreview(string $sourceFile, string $absoluteDestPath, |
208 | 229 |
|
209 | 230 | private function fixPromptEnvironment(): void |
210 | 231 | { |
211 | | - if (getenv('DDEV_PROJECT')) { |
212 | | - putenv('COLUMNS=100'); |
213 | | - putenv('LINES=40'); |
214 | | - putenv('TERM=xterm-256color'); |
215 | | - } |
| 232 | + $this->setPromptEnvironment(); |
216 | 233 | } |
217 | 234 | } |
0 commit comments