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

feat: fetch proxy configuration from NPM if any #9

Merged
merged 3 commits into from
Mar 4, 2020

Conversation

aslushnikov
Copy link
Contributor

Fixes #8

@coveralls
Copy link

coveralls commented Mar 2, 2020

Coverage Status

Coverage increased (+0.6%) to 98.611% when pulling efa5034 on aslushnikov:fetch-env-from-npm into e0d07a9 on Rob--W:master.

@Rob--W
Copy link
Owner

Rob--W commented Mar 2, 2020

Instead of adding new getEnv(...) calls everywhere, could you modify the getEnv to fall back to npm_config_* if needed?

And please add some unit tests as well.

@aslushnikov
Copy link
Contributor Author

aslushnikov commented Mar 2, 2020

Instead of adding new getEnv(...) calls everywhere, could you modify the getEnv to fall back to npm_config_* if needed?

Not all proxy-related env variables are mirrored in NPM config, e.g. there's no such thing as npm_config_all_proxy. I can whitelist allowed values in getEnv, but having these ad-hoc feels more straight-forward.

And please add some unit tests as well.

My bad! Done.

@Rob--W
Copy link
Owner

Rob--W commented Mar 2, 2020

Not all proxy-related env variables are mirrored in NPM config, e.g. there's no such thing as npm_config_all_proxy

I see. There is no 1:1 relation between the variable names used here and the one used by npm.

Could you use the npm_config_ variants as a fallback? The HTTPS_PROXY (etc) variable is the more common form, so they should be preferred over the npm_config variants.

And please add some unit tests as well.

My bad! Done.

Thaanks!

@aslushnikov
Copy link
Contributor Author

Could you use the npm_config_ variants as a fallback? The HTTPS_PROXY (etc) variable is the more common form, so they should be preferred over the npm_config variants.

I was driven by an opposite logic: preferring npm_config_* over default variants since they're more specific.

I consider the following use case: I have HTTPS_PROXY somewhere in my .bashrc for general-purpose web surfing, and if NPM doesn't work for some reason with these settings then I go figure all the npm-config business. WDYT?

@Rob--W
Copy link
Owner

Rob--W commented Mar 3, 2020

Could you use the npm_config_ variants as a fallback? The HTTPS_PROXY (etc) variable is the more common form, so they should be preferred over the npm_config variants.

I was driven by an opposite logic: preferring npm_config_* over default variants since they're more specific.

I consider the following use case: I have HTTPS_PROXY somewhere in my .bashrc for general-purpose web surfing, and if NPM doesn't work for some reason with these settings then I go figure all the npm-config business. WDYT?

This sounds reasonable. I also looked up the origin of the npm config documentation, and found that it was introduced here: npm/npm#6525

In that implementation, the default value of npm_config_*proxy is unset, to allow the underlying (request) library to observe the standard *_PROXY environment variable. If npm_config_*proxy is set, the *_proxy environment variable is shadowed.

In your current patch, you're using the npm-specific environment variables before falling back to the normal ones, i.e.:

  1. npm_config_[proto]_proxy
  2. npm_config_proxy
  3. [proto]_proxy
  4. all_proxy

Could you swap 2 and 3, so that the protocol-specific environment variables take precedence over the ultimate fallback?

@aslushnikov
Copy link
Contributor Author

Could you swap 2 and 3, so that the protocol-specific environment variables take precedence over the ultimate fallback?

Indeed, good catch! Done.

@aslushnikov
Copy link
Contributor Author

is there anything else I can do?

@Rob--W Rob--W merged commit eead613 into Rob--W:master Mar 4, 2020
@Rob--W
Copy link
Owner

Rob--W commented Mar 4, 2020

Thanks for your patch. Is there anything else before I publish an update?

@aslushnikov
Copy link
Contributor Author

Thanks for your patch. Is there anything else before I publish an update?

No, I don't think so. Once you release a new version, we'll bump it right away in Playwright.

Thank you!

@aslushnikov aslushnikov deleted the fetch-env-from-npm branch March 4, 2020 02:18
Rob--W added a commit that referenced this pull request Mar 4, 2020
Rob--W added a commit that referenced this pull request Mar 4, 2020
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.

Respect NPM configuration
3 participants