Scripts: coerce live reload port to integer #29196
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Attempting to use
process.env.WP_LIVE_RELOAD_PORTwas not working for me. After some debugging, I realizedwebpack-livereload-pluginmust not expect to receive a port argument of astringtype, failing silently to take the desired port, and perprocess.envdocs:Additionally, the use of the logical OR operator would prevent passing a
0value, precluding the use of the followingwebpack-livereload-pluginfunctionality:This PR aims to remedy this by parsing
process.env.WP_LIVE_RELOAD_PORTbefore passing the value towebpack-livereload-plugin.How has this been tested?
Validated by running these changes against a local project. Before the change, running
wp-scripts startwould always log one of the two below:Live Reload listening on port 35729Live Reload disabled: listen EADDRINUSE: address already in use :::35729(for parallel processes run)After the changes in this PR, the appropriate port will be used — including the use of a
0value.Types of changes
Bug fix (non-breaking change which fixes an issue)
Checklist: