- Issue created by @RichardGaunt
- 🇦🇺Australia alan.cole
As this is to resolve an issue with the build script where it's unable to find the civictheme path, rather than hard-code a path in as part of the update script, we could resolve the path at runtime within the build script.
Example:
const DIR_CIVICTHEME = getCivicthemeDir(PATH) // ... function getCivicthemeDir(subthemeDir) { let currentDir = subthemeDir while (currentDir !== path.parse(currentDir).root) { if (path.parse(currentDir).name === 'themes') { const civicthemePath = globSync(currentDir + '/**/civictheme').pop() if (fs.existsSync(civicthemePath) && fs.lstatSync(civicthemePath).isDirectory()) { return path.relative(civicthemePath, subthemeDir) } } currentDir = path.dirname(currentDir) } errorReporter('Could not find civictheme directory.') }
- 🇦🇺Australia alan.cole
2 PRs have been raised to update the drupal and UI Kit:
- This script update provides a way for subthemes to automatically find the civictheme base class, assuming that the subtheme and base theme both live in the themes folder in Drupal.
- This change was needed because the location of the civictheme base class can be different per implementation. Some projects use /contrib/ and /custom/, some put all themes in the same parent directory.
- If the parent theme is expected to live in a vastly different directory, the base theme class can still be set manually, e.g.
const DIR_CIVICTHEME = config.base ? null : `/any/directory/path/civictheme`
- This change also implements a few more checks for
config.base ? null : ...
for other variables. This is because some variables are only required if building for subtheme. This change, as well as avoiding setting variables that aren't required, also makes it clearer which variables are not used with the base theme.