Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d09cf7

Browse files
committed
Remove ScriptHandler::getDrupalRoot retrieve the data from composer metadata (via DrupalFinder)
1 parent 2f45db3 commit 2d09cf7

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

composer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
"drupal-composer/drupal-scaffold": "^2.2",
2222
"drupal/console": "~1.0",
2323
"drupal/core": "~8.0",
24-
"drush/drush": "~8.0"
24+
"drush/drush": "~8.0",
25+
"webflo/drupal-finder": "^0.2.1",
26+
"webmozart/path-util": "^2.3"
2527
},
2628
"require-dev": {
2729
"behat/mink": "~1.7",

scripts/composer/ScriptHandler.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,17 @@
99

1010
use Composer\Script\Event;
1111
use Composer\Semver\Comparator;
12+
use DrupalFinder\DrupalFinder;
1213
use Symfony\Component\Filesystem\Filesystem;
1314
use Webmozart\PathUtil\Path;
1415

1516
class ScriptHandler {
1617

17-
protected static function getDrupalRoot($project_root) {
18-
return $project_root . '/web';
19-
}
20-
2118
public static function createRequiredFiles(Event $event) {
2219
$fs = new Filesystem();
23-
$projectRoot = getcwd();
24-
$drupalRoot = static::getDrupalRoot($projectRoot);
20+
$drupalFinder = new DrupalFinder();
21+
$drupalFinder->locateRoot(getcwd());
22+
$drupalRoot = $drupalFinder->getDrupalRoot();
2523

2624
$dirs = [
2725
'modules',
@@ -44,7 +42,7 @@ public static function createRequiredFiles(Event $event) {
4442
require_once $drupalRoot . '/core/includes/install.inc';
4543
$settings['config_directories'] = [
4644
CONFIG_SYNC_DIRECTORY => (object) [
47-
'value' => Path::makeRelative($projectRoot . '/config/sync', $drupalRoot),
45+
'value' => Path::makeRelative($drupalFinder->getComposerRoot() . '/config/sync', $drupalRoot),
4846
'required' => TRUE,
4947
],
5048
];

0 commit comments

Comments
 (0)