create-profile.sh: use a variable for the profile destination directory
authorAntonio Ospite <ao2@ao2.it>
Sat, 10 Mar 2018 21:29:57 +0000 (22:29 +0100)
committerAntonio Ospite <ao2@ao2.it>
Fri, 16 Mar 2018 12:30:04 +0000 (13:30 +0100)
This is to avoid some repetitions.

libexec/create-profile.sh

index aa627b0..84ab022 100755 (executable)
@@ -64,7 +64,9 @@ DRUSH="${PROJECT_ROOT}/vendor/bin/drush"
 [ -x "$DRUSH" ] || { echo "Aborting, '$DRUSH' not available." 1>&2; exit 1; }
 [ -x "$DRUPAL_CONSOLE" ] || { echo "Aborting, '$DRUPAL_CONSOLE' not available." 1>&2; exit 1; }
 
 [ -x "$DRUSH" ] || { echo "Aborting, '$DRUSH' not available." 1>&2; exit 1; }
 [ -x "$DRUPAL_CONSOLE" ] || { echo "Aborting, '$DRUPAL_CONSOLE' not available." 1>&2; exit 1; }
 
-[ -d "${PROJECT_ROOT}/${PROFILE_MACHINE_NAME}" ] && { echo "Aborting, ${PROJECT_ROOT}/${PROFILE_MACHINE_NAME} already exists." 1>&2; exit 1; }
+PROFILE_DEST_DIR="${PROJECT_ROOT}/${PROFILE_MACHINE_NAME}"
+
+[ -d "${PROFILE_DEST_DIR}" ] && { echo "Aborting, '${PROFILE_DEST_DIR}' already exists." 1>&2; exit 1; }
 
 pushd "$WEB_ROOT"
 
 
 pushd "$WEB_ROOT"
 
@@ -76,7 +78,7 @@ pushd "$WEB_ROOT"
 #
 # or
 #
 #
 # or
 #
-#  $DRUPAL_CONSOLE yaml:get:value "$PWD/$PROFILE_MACHINE_NAME/config/install/core.extension.yml" dependencies
+#  $DRUPAL_CONSOLE yaml:get:value "${PROFILE_DEST_DIR}/config/install/core.extension.yml" dependencies
 #
 # However getting them before exporting the configuration and generating the
 # profile is cleaner.
 #
 # However getting them before exporting the configuration and generating the
 # profile is cleaner.
@@ -95,21 +97,21 @@ $DRUPAL_CONSOLE generate:profile \
 
 # Basically do what's suggested in the "Configuration" section here:
 # https://www.drupal.org/docs/8/creating-distributions/how-to-write-a-drupal-8-installation-profile
 
 # Basically do what's suggested in the "Configuration" section here:
 # https://www.drupal.org/docs/8/creating-distributions/how-to-write-a-drupal-8-installation-profile
-$DRUPAL_CONSOLE config:export --directory="${PROJECT_ROOT}/${PROFILE_MACHINE_NAME}/config/install" --remove-uuid --remove-config-hash
-rm "${PROJECT_ROOT}/${PROFILE_MACHINE_NAME}/config/install/core.extension.yml"
+$DRUPAL_CONSOLE config:export --directory="${PROFILE_DEST_DIR}/config/install" --remove-uuid --remove-config-hash
+rm "${PROFILE_DEST_DIR}/config/install/core.extension.yml"
 
 # The reference to the core version could be removed, even though it is not strictly necessary.
 
 # The reference to the core version could be removed, even though it is not strictly necessary.
-find "${PROJECT_ROOT}/${PROFILE_MACHINE_NAME}/config/install" -type f -exec sed -i -e '/^_core: {  }/d' {} \;
+find "${PROFILE_DEST_DIR}/config/install" -type f -exec sed -i -e '/^_core: {  }/d' {} \;
 
 # Since the profile generated by `$DRUPAL_CONSOLE generate:profile` calls in
 # the standard profile, some duplicated config files could be removed in the
 # new profile, but that's not strictly necessary either.
 
 # Since the profile generated by `$DRUPAL_CONSOLE generate:profile` calls in
 # the standard profile, some duplicated config files could be removed in the
 # new profile, but that's not strictly necessary either.
-#fdupes -f -1 "${WEB_ROOT}/core/profiles/standard/config/install/" "${PROJECT_ROOT}/${PROFILE_MACHINE_NAME}/config/install/" | xargs rm
+#fdupes -f -1 "${WEB_ROOT}/core/profiles/standard/config/install/" "${PROFILE_DEST_DIR}/config/install/" | xargs rm
 
 # Export the default content if the default_content module is there
 if echo "$ENABLED_MODULES" | grep -q default_content;
 then
 
 # Export the default content if the default_content module is there
 if echo "$ENABLED_MODULES" | grep -q default_content;
 then
-  $DRUSH default-content-export-references --folder="${PROJECT_ROOT}/${PROFILE_MACHINE_NAME}/content" node
+  $DRUSH default-content-export-references --folder="${PROFILE_DEST_DIR}/content" node
 fi
 
 popd
 fi
 
 popd