browser-webdriver-downloader 2.0.6 → 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 +4 -0
- package/package.json +3 -1
- package/src/index.js +41 -2
package/README.md
CHANGED
@@ -7,3 +7,7 @@ Install and wrap msedgedriver in Node.js
|
|
7
7
|
Setting `EDGEDRIVER_VERSION` will prevent it from downloading latest, for example `EDGEDRIVER_VERSION=102.0.1245.33 npm install`.
|
8
8
|
|
9
9
|
Setting `DETECT_EDGEDRIVER_VERSION=true` will match your installed Edge version.
|
10
|
+
|
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.0
|
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, '');
|
@@ -140,7 +145,23 @@ function getDriverPath(driverName = getDriverName()) {
|
|
140
145
|
return path.resolve(driversRoot, driverName);
|
141
146
|
}
|
142
147
|
|
148
|
+
async function shouldSkipDownload() {
|
149
|
+
const { default: yn } = await import('yn');
|
150
|
+
|
151
|
+
let shouldSkipDownload = yn(process.env.SKIP_EDGEDRIVER_DOWNLOAD);
|
152
|
+
|
153
|
+
if (shouldSkipDownload) {
|
154
|
+
console.log(`SKIP_EDGEDRIVER_DOWNLOAD=${process.env.SKIP_EDGEDRIVER_DOWNLOAD}, skipping download`);
|
155
|
+
}
|
156
|
+
|
157
|
+
return shouldSkipDownload;
|
158
|
+
}
|
159
|
+
|
143
160
|
async function install() {
|
161
|
+
if (await shouldSkipDownload()) {
|
162
|
+
return;
|
163
|
+
}
|
164
|
+
|
144
165
|
let version = await getDriverVersion();
|
145
166
|
|
146
167
|
let driverName = getDriverName();
|
@@ -192,13 +213,15 @@ async function download({ tmpPath, version }) {
|
|
192
213
|
|
193
214
|
let downloadUrl = `${downloadHost}/${version}/${downloadName}`;
|
194
215
|
|
216
|
+
let options = getGotOptions(downloadUrl);
|
217
|
+
|
195
218
|
console.log(`Downloading ${downloadUrl}...`);
|
196
219
|
|
197
220
|
// eslint-disable-next-line node/no-missing-import
|
198
221
|
const { got } = await import('got');
|
199
222
|
|
200
223
|
await pipeline(
|
201
|
-
got.stream(downloadUrl),
|
224
|
+
got.stream(downloadUrl, options),
|
202
225
|
fs.createWriteStream(downloadPath),
|
203
226
|
);
|
204
227
|
|
@@ -241,7 +264,23 @@ async function hackLocalBinSymlink() {
|
|
241
264
|
}
|
242
265
|
}
|
243
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
|
+
|
244
282
|
module.exports = {
|
245
283
|
getDriverPath,
|
246
284
|
install,
|
285
|
+
getGotOptions,
|
247
286
|
};
|