Skip to content
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

Target localhost by default if $PORT is set, closes #146. #147

Merged
merged 5 commits into from
Jul 20, 2018

Conversation

goto-bus-stop
Copy link
Contributor

If the $PORT env variable is set, the URL defaults to
localhost:PORT/path. You can pass a bare path for the URL.

This allows doing:

0x --on-port 'autocannon /path' -- node server.js

When an invalid URL is given, autocannon now logs an error and exits.
(/path without a $PORT is an invalid URL.)

It uses the URL API which was backported to Node 6.13.0, if lower
versions of Node 6 should be supported I can change it to use
url.parse and url.format instead.

If the `$PORT` env variable is set, the URL defaults to
`localhost:PORT/path`. You can pass a bare path for the URL.

This allows doing:

    0x --on-port 'autocannon /path' -- node server.js
@goto-bus-stop goto-bus-stop mentioned this pull request Jul 20, 2018
Copy link
Owner

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -5,6 +5,7 @@
const minimist = require('minimist')
const fs = require('fs')
const path = require('path')
const URL = require('url').URL
Copy link
Owner

Choose a reason for hiding this comment

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

Can you throw an error if URL is not available?

@mcollina
Copy link
Owner

Can you please update the docs as well? CI is still failing :(.

@goto-bus-stop
Copy link
Contributor Author

CI failures seem like the same as in #145 (comment). It passed on Node 6 and 10 this time and failed on 8, looks like flakiness. I think it would be easiest to fix it in #144 to prevent merge conflicts.

@mcollina mcollina merged commit c227089 into mcollina:master Jul 20, 2018
@mcollina
Copy link
Owner

🎉 !

@goto-bus-stop goto-bus-stop deleted the env-port branch August 22, 2018 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants