diff --git a/scripts/composer/ScriptHandler.php b/scripts/composer/ScriptHandler.php index 837f0c740..9abe6d70b 100644 --- a/scripts/composer/ScriptHandler.php +++ b/scripts/composer/ScriptHandler.php @@ -11,9 +11,9 @@ use Composer\Semver\Comparator; use Drupal\Core\Site\Settings; use Drupal\Core\Site\SettingsEditor; -use DrupalFinder\DrupalFinder; use DrupalFinder\DrupalFinderComposerRuntime; use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Filesystem\Path; class ScriptHandler { @@ -22,6 +22,11 @@ public static function createRequiredFiles(Event $event) { $drupalFinder = new DrupalFinderComposerRuntime(); $drupalRoot = $drupalFinder->getDrupalRoot(); + if (is_null($drupalRoot)) { + $event->getIO()->writeError('Drupal root could not be detected.'); + exit(1); + } + $dirs = [ 'modules', 'profiles', @@ -43,7 +48,7 @@ public static function createRequiredFiles(Event $event) { require_once $drupalRoot . '/core/includes/install.inc'; new Settings([]); $settings['settings']['config_sync_directory'] = (object) [ - 'value' => '../config/sync', + 'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/sync', $drupalRoot), 'required' => TRUE, ]; SettingsEditor::rewrite($drupalRoot . '/sites/default/settings.php', $settings);