Skip to content

Commit

Permalink
Add or remove theme path from composer.json on generation / clean.
Browse files Browse the repository at this point in the history
  • Loading branch information
Edouard Cunibil committed Mar 15, 2022
1 parent cc14db1 commit fee1920
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/Command/CleanProjectCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,24 @@ protected function execute(InputInterface $input, OutputInterface $output) {
$dir = $theme_folder . '/' . $machine_name . '_theme';
if ($this->getFs()->exists($dir)) {
$this->getFs()->remove($dir);

// Remove the theme path in the composer.json file.
$prevDir = getcwd();
chdir($this->drupalFinder->getComposerRoot());
$enabledThemes = json_decode(exec('/usr/bin/env composer config extra.kumquat-themes'));

$prefix = substr($this->drupalFinder->getDrupalRoot(), strlen($this->drupalFinder->getComposerRoot()));
$prefix = trim($prefix, '/');
$key = array_search($prefix . '/' . $dir, $enabledThemes);
if ($key !== FALSE) {
unset($enabledThemes[$key]);
}

exec('/usr/bin/env composer config extra.kumquat-themes --json \'' . json_encode(array_unique($enabledThemes)) . '\'');
exec('/usr/bin/env composer update --lock');

chdir($prevDir);

$this->getIo()->success(sprintf('%s front theme successfully cleaned.', $machine_name . '_theme'));
}
else {
Expand Down
7 changes: 6 additions & 1 deletion src/Generator/ProjectGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,15 @@ public function generateDefaultTheme(array $parameters) {
// Add the theme path in the composer.json file.
$prevDir = getcwd();
chdir($this->drupalFinder->getComposerRoot());
$enabledThemes = json_decode(exec('/usr/bin/env composer config extra.kumquat-themes'));

$prefix = substr($this->drupalFinder->getDrupalRoot(), strlen($this->drupalFinder->getComposerRoot()));
$prefix = trim($prefix, '/');
exec('/usr/bin/env composer config extra.kumquat-themes.0 ' . $prefix . '/' . $defaultThemePath);
$enabledThemes[] = $prefix . '/' . $defaultThemePath;

exec('/usr/bin/env composer config extra.kumquat-themes --json \'' . json_encode(array_unique($enabledThemes)) . '\'');
exec('/usr/bin/env composer update --lock');

chdir($prevDir);
$this->fileQueue->addFile('../composer.json');
$this->countCodeLines->addCountCodeLines(1);
Expand Down

0 comments on commit fee1920

Please sign in to comment.