Skip to content

Commit

Permalink
Merge pull request #427 from carstencodes/contrib/carstencodes/fix-mj…
Browse files Browse the repository at this point in the history
…s-installer

fix: Proxy Agent usage
  • Loading branch information
yoheimuta authored Jul 31, 2024
2 parents 82662bf + b36be29 commit 5b01353
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bdist/js/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Protolint is a go based linter for `.proto` files for google protobuf und gRPC.

The npm package provides a wrapper around the executables `protolint` and `protoc-gen-protolint`. During installation process, it will download the binaries matching the version and your operating system and CPU architecture from github.

If your behind a proxy, you can add the `PROTOLINT_PROXY` environment variable including the HTTP basic authentication information like username and password.
If your behind a proxy, you can add the `PROTOLINT_PROXY` environment variable including the HTTP basic authentication information like username and password. **NOTE** that this will take precedence of the system `HTTP_PROXY`/`HTTPS_PROXY` environment variables. If these variables should be used, do not use `PROTOLINT_PROXY`. If a proxy server is set that should not be used, set `PROTOLINT_NO_PROXY` to non-zero value.

If your running an airgapped environment, you can add the following environment variables:

Expand Down
17 changes: 14 additions & 3 deletions bdist/js/install.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,19 @@ const arch = _arch_mapping[_arch] ?? _arch;
const url = `${protolint_host}/${protolint_path}/v${protolint_version}/${module_name}_${protolint_version}_${platform}_${arch}.tar.gz`;

let agent;
if (process.env.PROTOLINT_PROXY) {
agent = HttpProxyAgent(process.env.PROTOLINT_PROXY);

let proxy_address;

if (!process.env.PROTOLINT_NO_PROXY) {
proxy_address = process.env.PROTOLINT_PROXY;
if (!proxy_address)
{
proxy_address = protolint_host.startsWith("https") ? process.env.HTTPS_PROXY : process.env.HTTP_PROXY;
}
}

if (proxy_address) {
agent = new HttpProxyAgent(proxy_address);
}

const agent_config = {
Expand Down Expand Up @@ -175,4 +186,4 @@ fetch(url).then(
npmlog.error(script_name, "Failed to install protolint: %s", reason);
process.exit(1);
}
);
);

0 comments on commit 5b01353

Please sign in to comment.