Skip to content

Commit a6ac4e6

Browse files
balagan73AronNovak
andauthored
Improve auto update script (#918)
Co-authored-by: Aron Novak <[email protected]>
1 parent c103b45 commit a6ac4e6

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

robo-components/AutoUpdateTrait.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ public function updateModules() {
3939
// No need to update.
4040
continue;
4141
}
42+
// If recommended module is not compatible with current drupal
43+
// core, we skip the update.
44+
if (isset($project['releases'][$project['recommended']]['core_compatible']) && $project['releases'][$project['recommended']]['core_compatible'] === FALSE) {
45+
$this->say($project['name'] . ' (version ' . $project['recommended'] . ') is not compatible with current drupal core, skipping it.');
46+
continue;
47+
}
4248
$version = $project['recommended'];
4349
// Version numbers in drupal can take several patterns. We need to derive
4450
// the composer update command from any of them:
@@ -60,13 +66,17 @@ public function updateModules() {
6066
}
6167
}
6268

63-
$this->say('Updating ' . $package . ' to version ' . $version);
64-
$exit_code = $this->taskExec("composer update 'drupal/" . $package . ":^" . $version . "' -W")
69+
$this->say('Updating ' . $package . ' to version ^' . $version);
70+
// Update core in a separate subprocess, as otherwise composer
71+
// might get updated too, resulting in deleted files inside
72+
// the /vendor directory causing an error.
73+
$escaped_package = escapeshellarg('drupal/' . $package . ':^' . $version);
74+
$exit_code = $this->taskExec('bash -lc "exec composer update ' . $escaped_package . ' -W"')
6575
->printOutput(TRUE)
6676
->run()
6777
->getExitCode();
6878
if ($exit_code !== 0) {
69-
throw new \Exception("There was an error updating " . $package . " to version " . $version);
79+
throw new \Exception("There was an error updating " . $package . " to version ^" . $version);
7080
}
7181

7282
$current_branch = trim(`git symbolic-ref --short HEAD`);

0 commit comments

Comments
 (0)