Skip to content

Commit 2618274

Browse files
Merge pull request #406 from continuouspipe/feature/detect-m2-version-differently
Extract Magento2 version detection to a function.
2 parents 76e778b + 9fd4026 commit 2618274

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

magento2/usr/local/share/env/30-framework

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,3 @@ MAGENTO_ENABLE_CONFIG_WEBSERVICE_CACHE=$(convert_to_boolean_string "${MAGENTO_EN
168168
export MAGENTO_ENABLE_CONFIG_WEBSERVICE_CACHE
169169
MAGENTO_ENABLE_TARGET_RULE_CACHE=$(convert_to_boolean_string "${MAGENTO_ENABLE_TARGET_RULE_CACHE:-true}")
170170
export MAGENTO_ENABLE_TARGET_RULE_CACHE
171-
172-
MAGENTO_ENTERPRISE_EDITION=$(convert_to_boolean_string "${MAGENTO_ENTERPRISE_EDITION:-$(run_return_boolean has_composer_package "magento/product-enterprise-edition")}")
173-
export MAGENTO_ENTERPRISE_EDITION
174-
175-
export MAGENTO_VERSION="${MAGENTO_VERSION:-$(composer_package_version magento/product-community-edition | cut -d. -f1,2)}"

magento2/usr/local/share/env/60-framework

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,8 @@ export BUILD_MAGENTO_MODE=${BUILD_MAGENTO_MODE:-production}
88

99
# Support older configurations by setting original env vars
1010
export REDIS_HOST_PORT=${REDIS_PORT}
11+
12+
MAGENTO_ENTERPRISE_EDITION=$(convert_to_boolean_string "${MAGENTO_ENTERPRISE_EDITION:-$(run_return_boolean has_composer_package "magento/product-enterprise-edition")}")
13+
export MAGENTO_ENTERPRISE_EDITION
14+
15+
export MAGENTO_VERSION="${MAGENTO_VERSION:-$(detect_magento_version)}"

magento2/usr/local/share/magento2/magento_functions.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/bash
22

3+
function detect_magento_version() {
4+
if has_composer_package magento/product-community-edition; then
5+
composer_package_version magento/product-community-edition | cut -d. -f1,2
6+
else
7+
echo "2.1"
8+
fi
9+
}
10+
311
function do_composer_config() {
412
as_code_owner "composer global config repositories.magento composer https://repo.magento.com/"
513

@@ -408,12 +416,11 @@ function do_magento_download_magerun2() {
408416
chmod +x /app/bin/n98-magerun2.phar
409417
}
410418

411-
function remove_config_template() (
412-
set +e
419+
function remove_config_template() {
413420
if dpkg --compare-versions "$MAGENTO_VERSION" ge 2.2; then
414421
rm -f /etc/confd/conf.d/magento_config.php.toml /etc/confd/templates/magento/config.php.tmpl
415422
fi
416-
)
423+
}
417424

418425
function do_magento2_templating() {
419426
remove_config_template

0 commit comments

Comments
 (0)