browser-webdriver-downloader 2.1.0 → 2.2.1
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/bin/msedgedriver.js +2 -1
- package/package.json +4 -2
- package/src/index.js +29 -3
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/bin/msedgedriver.js
CHANGED
@@ -3,10 +3,11 @@
|
|
3
3
|
|
4
4
|
require('../src/utils/throw-up');
|
5
5
|
|
6
|
-
const execa = require('execa');
|
7
6
|
const { getDriverPath } = require('../src');
|
8
7
|
|
9
8
|
(async () => {
|
9
|
+
const { execa } = await import('execa');
|
10
|
+
|
10
11
|
await execa(getDriverPath(), process.argv.slice(2), {
|
11
12
|
stdio: 'inherit',
|
12
13
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "browser-webdriver-downloader",
|
3
|
-
"version": "2.1
|
3
|
+
"version": "2.2.1",
|
4
4
|
"description": "Install and wrap msedgedriver in Node.js",
|
5
5
|
"bin": {
|
6
6
|
"msedgedriver": "bin/msedgedriver.js"
|
@@ -42,11 +42,13 @@
|
|
42
42
|
"node": ">=16.13"
|
43
43
|
},
|
44
44
|
"dependencies": {
|
45
|
-
"execa": "^
|
45
|
+
"execa": "^6.0.0",
|
46
46
|
"extract-zip": "^2.0.1",
|
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
@@ -7,12 +7,14 @@ const extractZip = require('extract-zip');
|
|
7
7
|
const pipeline = promisify(require('stream').pipeline);
|
8
8
|
const os = require('os');
|
9
9
|
const { createTmpDir } = require('../src/tmp');
|
10
|
-
const
|
10
|
+
const { getProxyForUrl } = require('proxy-from-env');
|
11
|
+
const { HttpsProxyAgent } = require('https-proxy-agent');
|
11
12
|
|
12
13
|
const platform = os.platform();
|
13
14
|
const arch = os.arch();
|
14
15
|
|
15
16
|
const downloadHost = 'https://msedgedriver.azureedge.net';
|
17
|
+
const latestVersionUrl = `${downloadHost}/LATEST_STABLE`;
|
16
18
|
|
17
19
|
const driversRoot = path.join(__dirname, '../bin');
|
18
20
|
|
@@ -93,6 +95,8 @@ async function getDetectedDriverVersion() {
|
|
93
95
|
|
94
96
|
let ps;
|
95
97
|
|
98
|
+
const { execa } = await import('execa');
|
99
|
+
|
96
100
|
try {
|
97
101
|
ps = await execa(browserCmd, ['--version']);
|
98
102
|
} catch (err) {
|
@@ -117,10 +121,12 @@ async function getDetectedDriverVersion() {
|
|
117
121
|
}
|
118
122
|
|
119
123
|
async function getLatestDriverVersion() {
|
124
|
+
let options = getGotOptions(latestVersionUrl);
|
125
|
+
|
120
126
|
// eslint-disable-next-line node/no-missing-import
|
121
127
|
const { got } = await import('got');
|
122
128
|
|
123
|
-
let { body } = await got.get(
|
129
|
+
let { body } = await got.get(latestVersionUrl, options);
|
124
130
|
|
125
131
|
// For example: '��102.0.1245.33\r\n'
|
126
132
|
let version = body.replace(/[^\d.]/g, '');
|
@@ -166,6 +172,8 @@ async function install() {
|
|
166
172
|
let shouldDownload = true;
|
167
173
|
|
168
174
|
if (await fs.exists(driverPath)) {
|
175
|
+
const { execa } = await import('execa');
|
176
|
+
|
169
177
|
let ps = await execa(driverPath, ['--version']);
|
170
178
|
|
171
179
|
// "Microsoft Edge WebDriver 105.0.1343.53 (3a47f00402d579c8ba1fad7e143f9d73831b6765)"
|
@@ -208,13 +216,15 @@ async function download({ tmpPath, version }) {
|
|
208
216
|
|
209
217
|
let downloadUrl = `${downloadHost}/${version}/${downloadName}`;
|
210
218
|
|
219
|
+
let options = getGotOptions(downloadUrl);
|
220
|
+
|
211
221
|
console.log(`Downloading ${downloadUrl}...`);
|
212
222
|
|
213
223
|
// eslint-disable-next-line node/no-missing-import
|
214
224
|
const { got } = await import('got');
|
215
225
|
|
216
226
|
await pipeline(
|
217
|
-
got.stream(downloadUrl),
|
227
|
+
got.stream(downloadUrl, options),
|
218
228
|
fs.createWriteStream(downloadPath),
|
219
229
|
);
|
220
230
|
|
@@ -257,7 +267,23 @@ async function hackLocalBinSymlink() {
|
|
257
267
|
}
|
258
268
|
}
|
259
269
|
|
270
|
+
function getGotOptions(url) {
|
271
|
+
let options = {};
|
272
|
+
|
273
|
+
let proxyUrl = getProxyForUrl(url);
|
274
|
+
|
275
|
+
if (proxyUrl) {
|
276
|
+
options.agent = {
|
277
|
+
...options.agent,
|
278
|
+
https: new HttpsProxyAgent(proxyUrl),
|
279
|
+
};
|
280
|
+
}
|
281
|
+
|
282
|
+
return options;
|
283
|
+
}
|
284
|
+
|
260
285
|
module.exports = {
|
261
286
|
getDriverPath,
|
262
287
|
install,
|
288
|
+
getGotOptions,
|
263
289
|
};
|