From 98bc2d12d3ff5249b097ca0b9e3131c47f8584b1 Mon Sep 17 00:00:00 2001 From: David Shaal Date: Tue, 3 Jul 2018 00:09:25 -0400 Subject: [PATCH 1/5] Improving theme cloning process in order to minimize manual updates --- components/_patterns/01-atoms/04-images/icons/_icon.twig | 5 ++--- emulsify.php | 2 ++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/components/_patterns/01-atoms/04-images/icons/_icon.twig b/components/_patterns/01-atoms/04-images/icons/_icon.twig index e9728893..3245a4f3 100644 --- a/components/_patterns/01-atoms/04-images/icons/_icon.twig +++ b/components/_patterns/01-atoms/04-images/icons/_icon.twig @@ -8,10 +8,9 @@ */ #} {% set icon_base_class = icon_base_class|default('icon') %} -{# For Drupal: Update this path to match your theme directory structure #} {# For Pattern Lab: The icon_url is defined in _data/paths.json. No action is required #} -{% set icon_url = icon_url|default('/themes/custom/YOURTHEME/dist/img/sprite/') %} -{# Update `emulsify` here to your theme's machine name #} +{# For Drupal: The icon_url is defined in the following line #} +{% set icon_url = icon_url|default('/themes/custom/emulsify/dist/img/sprite/') %} {{ attach_library('emulsify/sprite') }} diff --git a/emulsify.php b/emulsify.php index a3bec1cd..64bf6992 100644 --- a/emulsify.php +++ b/emulsify.php @@ -408,6 +408,8 @@ function _emulsify_get_files_to_alter() { 'emulsify.theme', 'emulsify.breakpoints.yml', 'emulsify.libraries.yml', + 'templates/navigation/menu--main.html.twig', + 'components/_patterns/01-atoms/04-images/icons/_icon.twig', ); // If we would like to have a bare copy we use is slim option. if (drush_get_option('slim') === TRUE) { From 25998a8790cde6a47244b5ebd96e6acc302754b1 Mon Sep 17 00:00:00 2001 From: David Shaal Date: Tue, 3 Jul 2018 00:17:04 -0400 Subject: [PATCH 2/5] fixing comment line --- components/_patterns/01-atoms/04-images/icons/_icon.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/_patterns/01-atoms/04-images/icons/_icon.twig b/components/_patterns/01-atoms/04-images/icons/_icon.twig index 3245a4f3..5d055772 100644 --- a/components/_patterns/01-atoms/04-images/icons/_icon.twig +++ b/components/_patterns/01-atoms/04-images/icons/_icon.twig @@ -9,7 +9,7 @@ #} {% set icon_base_class = icon_base_class|default('icon') %} {# For Pattern Lab: The icon_url is defined in _data/paths.json. No action is required #} -{# For Drupal: The icon_url is defined in the following line #} +{# For Drupal: The icon_url is defined in the following line. No action is required #} {% set icon_url = icon_url|default('/themes/custom/emulsify/dist/img/sprite/') %} {{ attach_library('emulsify/sprite') }} From 1c572e370b71772d44622391f4010c9f46d1ad1b Mon Sep 17 00:00:00 2001 From: Ofer Shaal Date: Wed, 4 Jul 2018 23:58:51 -0400 Subject: [PATCH 3/5] remove a non-existing directory `components/css` --- emulsify.php | 1 - 1 file changed, 1 deletion(-) diff --git a/emulsify.php b/emulsify.php index 64bf6992..61d3781b 100644 --- a/emulsify.php +++ b/emulsify.php @@ -494,7 +494,6 @@ function _emulsify_get_files_to_copy() { 'components/_macros', 'components/_meta', 'components/_twig-components', - 'components/css', 'components/images', 'components/_patterns/style.scss', 'components/_patterns/00-base/global/01-colors', From 4b7adf433053a32aa5af64c71e08fb2dccc5b47a Mon Sep 17 00:00:00 2001 From: Ofer Shaal Date: Thu, 5 Jul 2018 00:00:46 -0400 Subject: [PATCH 4/5] Support the `-slim` option --- emulsify.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emulsify.php b/emulsify.php index 61d3781b..31051bf7 100644 --- a/emulsify.php +++ b/emulsify.php @@ -408,8 +408,6 @@ function _emulsify_get_files_to_alter() { 'emulsify.theme', 'emulsify.breakpoints.yml', 'emulsify.libraries.yml', - 'templates/navigation/menu--main.html.twig', - 'components/_patterns/01-atoms/04-images/icons/_icon.twig', ); // If we would like to have a bare copy we use is slim option. if (drush_get_option('slim') === TRUE) { @@ -417,6 +415,8 @@ function _emulsify_get_files_to_alter() { } else { return array_merge($default_array, array( + 'templates/navigation/menu--main.html.twig', + 'components/_patterns/01-atoms/04-images/icons/_icon.twig', 'components', 'templates', 'README.md', From 06d72cbe1ef45959e2988f06679c826b19f3c83e Mon Sep 17 00:00:00 2001 From: Ofer Shaal Date: Thu, 5 Jul 2018 12:50:55 -0400 Subject: [PATCH 5/5] Fixing the function _emulsify_alter_files (code by @ccjjmartin) --- emulsify.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/emulsify.php b/emulsify.php index 31051bf7..8cbebdcd 100644 --- a/emulsify.php +++ b/emulsify.php @@ -415,8 +415,6 @@ function _emulsify_get_files_to_alter() { } else { return array_merge($default_array, array( - 'templates/navigation/menu--main.html.twig', - 'components/_patterns/01-atoms/04-images/icons/_icon.twig', 'components', 'templates', 'README.md', @@ -551,7 +549,7 @@ function _emulsify_get_files_to_rename() { * @return boolean * A boolean representing the success or failure of the function. */ -function _emulsify_alter_files($theme_path, array $files_to_alter = array(), array $alterations = array(), $absolute = FALSE) { +function _emulsify_alter_files($theme_path, array $files_to_alter = array(), array $alterations = array(), $absolute = FALSE, int $depth = 0) { if (empty($files_to_alter) || empty($alterations)) { return TRUE; } @@ -569,11 +567,11 @@ function _emulsify_alter_files($theme_path, array $files_to_alter = array(), arr $files = scandir($file_path); $files = array_splice($files, 2); foreach ($files as $file) { - $processed_files[] = $file_path . $file; - } - $alter_status = _emulsify_alter_files($theme_path, $processed_files, $alterations, TRUE); - if ($alter_status === FALSE) { - return FALSE; + $processed_file = [$file_path . DIRECTORY_SEPARATOR . $file]; + $alter_status = _emulsify_alter_files($theme_path, $processed_file, $alterations, TRUE, $depth + 1); + if ($alter_status === FALSE) { + return FALSE; + } } } elseif ($file_type === 'file') {