Skip to content

[build-tools] Let updateEnv override existing values#3901

Open
sjchmiela wants to merge 1 commit into
stanley/env-allows-undefinedfrom
stanley/update-env-overrides-existing
Open

[build-tools] Let updateEnv override existing values#3901
sjchmiela wants to merge 1 commit into
stanley/env-allows-undefinedfrom
stanley/update-env-overrides-existing

Conversation

@sjchmiela

@sjchmiela sjchmiela commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Change BuildContext.updateEnv so incoming values override existing env values.
  • Add a regression test covering overrides and clearing via undefined.

Why

This makes updateEnv behave like an update operation and lets callers intentionally refresh or clear existing environment entries.

No idea how it existed so long like this. I guess the values we update with don't overlap with the values we already have that often.

Test Plan

CI should pass.

@sjchmiela sjchmiela added the no changelog PR that doesn't require a changelog entry label Jun 25, 2026
@sjchmiela sjchmiela changed the title [build-tools] Let updateEnv override existing values [build-tools] Let updateEnv override existing values Jun 25, 2026
@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.02%. Comparing base (1fcaa05) to head (5c24631).

Additional details and impacted files
@@                       Coverage Diff                        @@
##           stanley/env-allows-undefined    #3901      +/-   ##
================================================================
- Coverage                         59.04%   59.02%   -0.01%     
================================================================
  Files                               935      935              
  Lines                             40974    40946      -28     
  Branches                           8632     8624       -8     
================================================================
- Hits                              24187    24165      -22     
+ Misses                            16691    16686       -5     
+ Partials                             96       95       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adjusts BuildContext.updateEnv in @expo/build-tools to behave like a true “update” operation by letting incoming env entries override existing ones, and adds a regression test to lock in override + “clear via undefined” behavior.

Changes:

  • Changed BuildContext.updateEnv merge order so incoming env values take precedence over the existing context env.
  • Added a unit test verifying overwriting an existing env var and clearing one by setting it to undefined.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/build-tools/src/context.ts Swap spread order in updateEnv so updates override existing env values.
packages/build-tools/src/tests/context.test.ts Add regression test for overriding and clearing env entries via updateEnv.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sjchmiela sjchmiela force-pushed the stanley/update-env-overrides-existing branch from e83065d to e808064 Compare June 26, 2026 10:49
@sjchmiela sjchmiela force-pushed the stanley/env-allows-undefined branch from b5c5e54 to 45c3357 Compare June 26, 2026 10:52
@sjchmiela sjchmiela force-pushed the stanley/update-env-overrides-existing branch from e808064 to 43511f2 Compare June 26, 2026 10:53
@sjchmiela sjchmiela force-pushed the stanley/env-allows-undefined branch from 45c3357 to 1fcaa05 Compare June 26, 2026 11:14
@sjchmiela sjchmiela force-pushed the stanley/update-env-overrides-existing branch from 43511f2 to 5c24631 Compare June 26, 2026 11:16
@github-actions

Copy link
Copy Markdown

⏩ The changelog entry check has been skipped since the "no changelog" label is present.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog PR that doesn't require a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants