browser-webdriver-downloader 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/package.json +3 -1
- package/src/index.js +25 -2
package/README.md
CHANGED
@@ -9,3 +9,5 @@ Setting `EDGEDRIVER_VERSION` will prevent it from downloading latest, for exampl
|
|
9
9
|
Setting `DETECT_EDGEDRIVER_VERSION=true` will match your installed Edge version.
|
10
10
|
|
11
11
|
Setting `SKIP_EDGEDRIVER_DOWNLOAD=true` will skip the download.
|
12
|
+
|
13
|
+
Any supported proxy config from [proxy-from-env](https://www.npmjs.com/package/proxy-from-env) will work.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "browser-webdriver-downloader",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.2.0",
|
4
4
|
"description": "Install and wrap msedgedriver in Node.js",
|
5
5
|
"bin": {
|
6
6
|
"msedgedriver": "bin/msedgedriver.js"
|
@@ -47,6 +47,8 @@
|
|
47
47
|
"find-edge-version": "0.1.1",
|
48
48
|
"fs-extra": "^11.0.0",
|
49
49
|
"got": "^12.0.0",
|
50
|
+
"https-proxy-agent": "^7.0.2",
|
51
|
+
"proxy-from-env": "^1.1.0",
|
50
52
|
"tmp": "0.2.1",
|
51
53
|
"yn": "^5.0.0"
|
52
54
|
},
|
package/src/index.js
CHANGED
@@ -8,11 +8,14 @@ const pipeline = promisify(require('stream').pipeline);
|
|
8
8
|
const os = require('os');
|
9
9
|
const { createTmpDir } = require('../src/tmp');
|
10
10
|
const execa = require('execa');
|
11
|
+
const { getProxyForUrl } = require('proxy-from-env');
|
12
|
+
const { HttpsProxyAgent } = require('https-proxy-agent');
|
11
13
|
|
12
14
|
const platform = os.platform();
|
13
15
|
const arch = os.arch();
|
14
16
|
|
15
17
|
const downloadHost = 'https://msedgedriver.azureedge.net';
|
18
|
+
const latestVersionUrl = `${downloadHost}/LATEST_STABLE`;
|
16
19
|
|
17
20
|
const driversRoot = path.join(__dirname, '../bin');
|
18
21
|
|
@@ -117,10 +120,12 @@ async function getDetectedDriverVersion() {
|
|
117
120
|
}
|
118
121
|
|
119
122
|
async function getLatestDriverVersion() {
|
123
|
+
let options = getGotOptions(latestVersionUrl);
|
124
|
+
|
120
125
|
// eslint-disable-next-line node/no-missing-import
|
121
126
|
const { got } = await import('got');
|
122
127
|
|
123
|
-
let { body } = await got.get(
|
128
|
+
let { body } = await got.get(latestVersionUrl, options);
|
124
129
|
|
125
130
|
// For example: '��102.0.1245.33\r\n'
|
126
131
|
let version = body.replace(/[^\d.]/g, '');
|
@@ -208,13 +213,15 @@ async function download({ tmpPath, version }) {
|
|
208
213
|
|
209
214
|
let downloadUrl = `${downloadHost}/${version}/${downloadName}`;
|
210
215
|
|
216
|
+
let options = getGotOptions(downloadUrl);
|
217
|
+
|
211
218
|
console.log(`Downloading ${downloadUrl}...`);
|
212
219
|
|
213
220
|
// eslint-disable-next-line node/no-missing-import
|
214
221
|
const { got } = await import('got');
|
215
222
|
|
216
223
|
await pipeline(
|
217
|
-
got.stream(downloadUrl),
|
224
|
+
got.stream(downloadUrl, options),
|
218
225
|
fs.createWriteStream(downloadPath),
|
219
226
|
);
|
220
227
|
|
@@ -257,7 +264,23 @@ async function hackLocalBinSymlink() {
|
|
257
264
|
}
|
258
265
|
}
|
259
266
|
|
267
|
+
function getGotOptions(url) {
|
268
|
+
let options = {};
|
269
|
+
|
270
|
+
let proxyUrl = getProxyForUrl(url);
|
271
|
+
|
272
|
+
if (proxyUrl) {
|
273
|
+
options.agent = {
|
274
|
+
...options.agent,
|
275
|
+
https: new HttpsProxyAgent(proxyUrl),
|
276
|
+
};
|
277
|
+
}
|
278
|
+
|
279
|
+
return options;
|
280
|
+
}
|
281
|
+
|
260
282
|
module.exports = {
|
261
283
|
getDriverPath,
|
262
284
|
install,
|
285
|
+
getGotOptions,
|
263
286
|
};
|