Skip to content

Commit

Permalink
try saving changed themes as dir + name tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
Vicente Canales committed Apr 27, 2024
1 parent 1e43c75 commit 4dbaec4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 0 additions & 2 deletions .github/scripts/create-preview-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ function createBlueprint(themeSlug, branch) {
* @returns {string} - The name of the theme as defined in the `style.css` file.
*/
function getThemeName(themeSlug) {
execSync`git checkout ${context.payload.pull_request.head.ref} -- ${themeSlug}/style.css`;
const styleCss = fs.readFileSync(`${themeSlug}/style.css`, 'utf8');
const themeName = styleCss.match(/Theme Name:(.*)/i)[1].trim();
return themeName;
Expand All @@ -54,7 +53,6 @@ function getThemeName(themeSlug) {
* @returns {string} - The name of the parent theme as defined in the `style.css` file.
*/
function getParentThemeName(themeSlug) {
execSync`git checkout ${context.payload.pull_request.head.ref} -- ${themeSlug}/style.css`;
const styleCss = fs.readFileSync(`${themeSlug}/style.css`, 'utf8');
const parentTheme = styleCss.match(/Template:(.*)/i);
const isChildTheme = parentTheme && '' !== parentTheme[1].trim();
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/preview-theme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ jobs:
dir_name=$(dirname "$file")
while [[ "$dir_name" != "." ]]; do
if [[ -f "$dir_name/style.css" ]]; then # Check if the parent directory contains a theme
# Save only the basename
unique_dirs[$dir_name]=$(basename $dir_name)
# Get theme name from style.css
theme_name=$(grep -m 1 "Theme Name:" "$dir_name/style.css" | sed 's/Theme Name: //')
# Store theme name and directory in associative array
unique_dirs["$dir_name"]=$theme_name
break
fi
dir_name=$(dirname "$dir_name")
Expand Down

0 comments on commit 4dbaec4

Please sign in to comment.