Skip to content

Handle SHOPIFY_FLAG_ENVIRONMENT correctly when passed as an environment variable #6000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025

Conversation

EvilGenius13
Copy link
Contributor

@EvilGenius13 EvilGenius13 commented Jun 18, 2025

WHY are these changes introduced?

Fixes #5594

When using the environment variable SHOPIFY_FLAG_ENVIRONMENT, you would get inconsistent behaviour. Sometimes it would read use the environment and sometimes it would ignore it and use a default or cached value.

In base-command at const environments = flags.environment ?? [] if flags.environment = myshop then environments.length would end up as 6 and skip additional processing.

WHAT is this pull request doing?

Ensure, environments ends up as an array.

How to test your changes?

Setup

  • Pull down the branch
  • Build the branch
  • Make sure you have a shopify.theme.toml file with a few environments.
  • In your terminal or bash profile, add `export SHOPIFY_FLAG_ENVIRONMENT=
  • run echo $SHOPIFY_FLAG_ENVIRONMENT and make sure you see the environment output
    Testing
  • Run shopify theme dev -e
  • Run shopify theme dev and check if it uses
  • Do the same with shopify theme list
  • Change to and ensure using SHOPIFY_FLAG_ENVIRONMENT overrides a default env.

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor

github-actions bot commented Jun 18, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
78.32% (-0% 🔻)
12541/16013
🟡 Branches
72.48% (+0.02% 🔼)
6102/8419
🟡 Functions
78.44% (-0.02% 🔻)
3271/4170
🟡 Lines
78.76% (+0.01% 🔼)
11868/15068
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / Dev.tsx
90.59% (-2.35% 🔻)
75% (-1.79% 🔻)
86.36% (-4.55% 🔻)
92.5% (-1.25% 🔻)
🟢
... / ConcurrentOutput.tsx
98.36% (-1.64% 🔻)
92% (-4% 🔻)
100%
98.33% (-1.67% 🔻)
🟢
... / base-command.ts
87.1% (+0.28% 🔼)
86.36% (-1.14% 🔻)
82.61%
88.89% (+0.28% 🔼)

Test suite run success

2898 tests passing in 1258 suites.

Report generated by 🧪jest coverage report action from 0edf793

@EvilGenius13 EvilGenius13 marked this pull request as ready for review June 18, 2025 20:33
@EvilGenius13 EvilGenius13 requested a review from a team as a code owner June 18, 2025 20:33

This comment has been minimized.

@EvilGenius13 EvilGenius13 requested a review from a team as a code owner June 18, 2025 20:38
…nt variable

This change ensures that the SHOPIFY_FLAG_ENVIRONMENT environment variable is correctly
parsed and used when passed as an environment variable.
@EvilGenius13 EvilGenius13 added this pull request to the merge queue Jun 20, 2025
Merged via the queue into main with commit bec79d4 Jun 20, 2025
30 checks passed
@EvilGenius13 EvilGenius13 deleted the env-flag branch June 20, 2025 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Themes CLI > 3.60.0 does not evaluate SHOPIFY_FLAG_ENVIRONMENT
3 participants