Fix PORT environment variable being ignored
I noticed that bin/reload does not respect the PORT environment variable contradicting
$ ./bin/reload --help | grep -A 2 -- --port
-p, --port [port] The port to bind to. Can be set with PORT env
variable as well. Defaults to 8080. (default:
"8080")
This provides a quick fix for this.
If provided, --port will take precedence.
Thanks for the PR and sorry for the long reply. Command line arguments are meant to task precedence over environment variables. With that being said I'm going to close this
(Light) Reference: https://stackoverflow.com/questions/11077223/what-order-of-reading-configuration-values
My patch is respecting the order the StackOverflow post is proposing.
- If
--port [port]is present,portwill be used (command line argument) - If
--port [port]is not present, but thePORTenvironment variable is, thenPORTis used (environment) - If
PORTis not present,8080is used (global configuration)
My point was that the PORT environment variable is never used, even though the documentation says it does.
Your current implementation does the following:
- If
--port [port]is present,portwill be used (command line argument) - If
--port [port]is not present,8080is used (global configuration)
The doc says, PORT will be used, but it never is.
Example:
$ PORT=1234 npx reload .
npx: Installierte 52 in 2.739s
Reload web server:
listening on port 8080
The server should listen on port 1234, but instead it listens on 8080.
Please reconsider merging my PR.
Codecov Report
Merging #280 (8cda46a) into master (39f2dc8) will not change coverage. The diff coverage is
n/a.
@@ Coverage Diff @@
## master #280 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 2 2
Lines 131 131
=========================================
Hits 131 131
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update 39f2dc8...8cda46a. Read the comment docs.
Thanks for reopening. Are there still any objections against merging this?