Skip to content

Commit 28d741c

Browse files
authored
[config:export] fix path construction (#4245) (#4246)
- Use Drupal root, not Composer root. - Avoid adding the root to an already absolute path. - Avoid adding the root twice when creating the directory.
1 parent 129c824 commit 28d741c

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

src/Command/Config/ExportCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Drupal\Console\Core\Command\Command;
1919
use Symfony\Component\Filesystem\Filesystem;
2020
use Drupal\Core\Config\ConfigManager;
21+
use Webmozart\PathUtil\Path;
2122

2223
class ExportCommand extends Command
2324
{
@@ -95,20 +96,22 @@ protected function interact(InputInterface $input, OutputInterface $output)
9596
*/
9697
protected function execute(InputInterface $input, OutputInterface $output)
9798
{
98-
$drupal_root = $this->drupalFinder->getComposerRoot();
99-
$directory = $drupal_root.'/'.$input->getOption('directory');
99+
$directory = $input->getOption('directory');
100100
$tar = $input->getOption('tar');
101101
$removeUuid = $input->getOption('remove-uuid');
102102
$removeHash = $input->getOption('remove-config-hash');
103-
$drupal_root = $this->drupalFinder->getComposerRoot();
104103

105104
if (!$directory) {
106105
$directory = Settings::get('config_sync_directory') ;
107106
}
107+
if (!Path::isAbsolute($directory)) {
108+
$drupal_root = $this->drupalFinder->getDrupalRoot();
109+
$directory = $drupal_root . "/" . $directory;
110+
}
108111

109112
$fileSystem = new Filesystem();
110113
try {
111-
$fileSystem->mkdir($drupal_root."/".$directory);
114+
$fileSystem->mkdir($directory);
112115
} catch (IOExceptionInterface $e) {
113116
$this->getIo()->error(
114117
sprintf(

0 commit comments

Comments
 (0)