Skip to content

Commit

Permalink
fix(stylua-npm-bin): adjust axios config to work with proxy env varia…
Browse files Browse the repository at this point in the history
…bles (#868)
  • Loading branch information
antoineauger authored Jun 19, 2024
1 parent 8642f6b commit 1ad8d05
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions stylua-npm-bin/binary.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const os = require("os");
const axios = require("axios");
const unzip = require("unzipper");
const rimraf = require("rimraf");
const { ProxyAgent } = require('proxy-agent');
const { join } = require("path");
const { existsSync, mkdirSync, createWriteStream } = require("fs");
const { spawnSync } = require("child_process");
Expand Down Expand Up @@ -44,8 +45,12 @@ const error = (msg) => {
};

const downloadArtifact = (url, location) => {
const agent = new ProxyAgent();
return new Promise((resolve, reject) => {
axios
// proxy: false is needed, otherwise axios is trying to overwrite the agent
// See https://github.com/axios/axios/issues/4531
.create({ proxy: false, httpAgent: agent, httpsAgent: agent })
.get(url, { responseType: "stream" })
.then((res) => res.data.pipe(unzip.Parse()))
.then((stream) => {
Expand Down
1 change: 1 addition & 0 deletions stylua-npm-bin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"dependencies": {
"axios": "^1.6.0",
"node-fetch": "^3.2.10",
"proxy-agent": "^6.4.0",
"rimraf": "^3.0.2",
"unzipper": "^0.10.11"
}
Expand Down

0 comments on commit 1ad8d05

Please sign in to comment.