Skip to content

Commit 8df5fd0

Browse files
dermatzCopilot
andauthored
Update src/Console/Command/Theme/CopyFromVendorCommand.php
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent ca088d1 commit 8df5fd0

1 file changed

Lines changed: 24 additions & 29 deletions

File tree

src/Console/Command/Theme/CopyFromVendorCommand.php

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,40 +43,35 @@ protected function configure(): void
4343

4444
protected function executeCommand(InputInterface $input, OutputInterface $output): int
4545
{
46-
try {
47-
$sourceFileArg = $input->getArgument('file');
48-
$isDryRun = $input->getOption('dry-run');
49-
$absoluteSourcePath = $this->getAbsoluteSourcePath($sourceFileArg);
50-
51-
// Update sourceFileArg if it was normalized to relative path
52-
$rootPath = $this->directoryList->getRoot();
53-
$sourceFile = str_starts_with($absoluteSourcePath, $rootPath . '/')
54-
? substr($absoluteSourcePath, strlen($rootPath) + 1)
55-
: $sourceFileArg;
56-
57-
$themeCode = $this->getThemeCode($input);
58-
$themePath = $this->getThemePath($themeCode);
59-
60-
$destinationPath = $this->vendorFileMapper->mapToThemePath($sourceFile, $themePath);
61-
$absoluteDestPath = $this->getAbsoluteDestPath($destinationPath, $rootPath);
62-
63-
if ($isDryRun) {
64-
$this->showDryRunPreview($sourceFile, $absoluteDestPath, $rootPath);
65-
return Cli::RETURN_SUCCESS;
66-
}
46+
$sourceFileArg = $input->getArgument('file');
47+
$isDryRun = $input->getOption('dry-run');
48+
$absoluteSourcePath = $this->getAbsoluteSourcePath($sourceFileArg);
6749

68-
if (!$this->confirmCopy($sourceFile, $absoluteDestPath, $rootPath)) {
69-
return Cli::RETURN_SUCCESS;
70-
}
50+
// Update sourceFileArg if it was normalized to relative path
51+
$rootPath = $this->directoryList->getRoot();
52+
$sourceFile = str_starts_with($absoluteSourcePath, $rootPath . '/')
53+
? substr($absoluteSourcePath, strlen($rootPath) + 1)
54+
: $sourceFileArg;
7155

72-
$this->performCopy($absoluteSourcePath, $absoluteDestPath);
73-
$this->io->success("File copied successfully.");
56+
$themeCode = $this->getThemeCode($input);
57+
$themePath = $this->getThemePath($themeCode);
7458

59+
$destinationPath = $this->vendorFileMapper->mapToThemePath($sourceFile, $themePath);
60+
$absoluteDestPath = $this->getAbsoluteDestPath($destinationPath, $rootPath);
61+
62+
if ($isDryRun) {
63+
$this->showDryRunPreview($sourceFile, $absoluteDestPath, $rootPath);
7564
return Cli::RETURN_SUCCESS;
76-
} catch (\Exception $e) {
77-
$this->io->error($e->getMessage());
78-
return Cli::RETURN_FAILURE;
7965
}
66+
67+
if (!$this->confirmCopy($sourceFile, $absoluteDestPath, $rootPath)) {
68+
return Cli::RETURN_SUCCESS;
69+
}
70+
71+
$this->performCopy($absoluteSourcePath, $absoluteDestPath);
72+
$this->io->success("File copied successfully.");
73+
74+
return Cli::RETURN_SUCCESS;
8075
}
8176

8277
private function getAbsoluteSourcePath(string $sourceFile): string

0 commit comments

Comments
 (0)