-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
wp-env: Set core source to latest when null #43133
Conversation
Size Change: 0 B Total Size: 1.28 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would you feel about moving the version default to parseConfig()
? The conversion from null
to "latest"
might make the most sense there since we're really just parsing the null
. Given that we won't need the fallback in withOverrides()
and that we're already caching getLatestWordPressVersion()
, that might be the most semantically correct.
49cd8b4
to
df37932
Compare
packages/env/lib/config/config.js
Outdated
const env = allEnvs.reduce( ( result, environment ) => { | ||
result[ environment ] = parseConfig( | ||
const env = {}; | ||
for ( const envName in allEnvs ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved away from reduce
because it's a lot easier to do async/await in a plain for loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @noahtallen, I appreciate the changes you made, this approach looks cleaner. I'm unable to test it right now because of the way I've set up Docker (Something is going wrong with argument passing to docker-compose
). I've added two suggestions that I think might be aligned with the current "parsing of null
" idea, but, it's probably not a big deal.
8905b20
to
5c7914e
Compare
Nice, I like that idea! Added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and tests well!
* Set core source to latest if config.core is null to fix a crash * Cache WordPress version to avoid extra network requests
What?
On trunk, there is a bug where if
.wp-env.json
sets"core": null
, wp-env will crash. This PR handles that case.Fixes #43222
Why?
The object spread operators which merge all of the configurations together override the default "latest version" string with this null value.
How?
In the overrides section of the config, we check if any of the core source values are still null, and then manually set the versions if needed. This means the core source should never be null.
Testing Instructions
null
npx wp-env start --debug
. Observe that the core source in the printed config file is null and that wp-env crashes.npx wp-env start --debug
. It should start successfully, and you should see a git core source printed in the config file.