Closed lukejacksonn closed 4 years ago
+1! If you end up merging/releasing this lmk and I'll make servor the default server in our docs.
Awesome work on the project btw! Impressed by how much this does without a single dep
Ok, given that there are no objections here and I have had chance to sleep on the decision (I see very few downsides) I am going merge and publish this as 3.1.0
🎉
Great! Just updated the docs to use this!
$ npx servor
npx: installed 1 in 2.219s
$ npx servor
npx: installed 1 in 0.864s
$ npx servor
npx: installed 1 in 0.876s
I could run this all day :)
As discussed in #34 having the server starting on a completely random port (if no port is explicitly provided) can be confusing for non power users.
This PR address the issue by changing this behaviour. The port selection behaviour is now as follows:
servor . index.html 1337
) or as an environment variable (for examplePORT=1337 servor
) then try start the server on the specified port. If this fails thenprocess.exit
and log that the specified port is already in use.8080
. If this fails then start the server on a random available port.This behaviour aligns better with other local file server modules (which usually pick a default port to run on, albeit usually failing if they cannot do so) and so hopefully helps eliminate some potential for confusion.