From 8a5fc20b398e1437a3e3be9b37d9a97cc9b1edc6 Mon Sep 17 00:00:00 2001 From: Dzmitry Lemechko Date: Tue, 7 Apr 2020 18:30:40 +0300 Subject: [PATCH] update npm config property and PATH names --- README.md | 42 +++++++++++++++++++++++++++++------------- src/index.ts | 6 +++--- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 30efd39..d51bfa2 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ const edgePaths = await installDriver(); const edgeOptions = new edge.Options(); edgeOptions.setEdgeChromium(true); edgeOptions.setBinaryPath(edgePaths.browserPath); -const driver = new Builder() +const driver = await new Builder() .forBrowser('MicrosoftEdge') .setEdgeOptions(edgeOptions) .setEdgeService(new edge.ServiceBuilder(edgePaths.driverPath)) @@ -40,11 +40,11 @@ const driver = new Builder() ## Custom binaries url -To use a mirror of the MSEdgeDriver binaries use PATH variable `EDGE_DRIVER_CDNURL`. +To use a mirror of the MSEdgeDriver binaries use PATH variable `EDGEDRIVER_CDNURL`. Default is `https://msedgedriver.azureedge.net`. ```shell -EDGE_DRIVER_CDNURL=https:// npm install ms-chromium-edge-driver +EDGEDRIVER_CDNURL=https:// npm install ms-chromium-edge-driver ``` ## Custom browser binary path and driver version @@ -58,7 +58,7 @@ npm install ms-chromium-edge-driver --npm_config_edge_binary_path=/path/to/Micro Another option is to use the PATH variable `EDGE_BINARY_PATH` ```shell -EDGE_BINARY_PATH=C:\\Program Files (x86)\\Microsoft\\Edge\\Application +EDGE_BINARY_PATH=C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe ``` On Windows there is an option to pass custom HKEY by using the PATH variable `EDGE_HKEY`: @@ -67,42 +67,58 @@ On Windows there is an option to pass custom HKEY by using the PATH variable `ED EDGE_HKEY=SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\Current\\Version\\Uninstall\\Microsoft Edge ``` -In addition, custom driver version can be specified with the npm config property `npm_config_edge_driver_version` +In addition, custom driver version can be specified with the npm config property `npm_config_edgedriver_version` ```shell -npm install ms-chromium-edge-driver --npm_config_edge_driver_version=80.0.361.103 +npm install ms-chromium-edge-driver --npm_config_edgedriver_version=80.0.361.103 ``` -Another option is to use the PATH variable `EDGE_DRIVER_VERSION` +Another option is to use the PATH variable `EDGEDRIVER_VERSION` ```shell -EDGE_DRIVER_VERSION=80.0.361.103 +EDGEDRIVER_VERSION=80.0.361.103 ``` If both browser binary path and version are provided, the package will skip binary fetch step and start with the driver download. ## Custom driver binary -To get the msedgedriver from the filesystem instead of a web request use the npm config property `npm_config_edge_driver_path`. +To get the msedgedriver from the filesystem instead of a web request use the npm config property `npm_config_edgedriver_path`. ```shell -npm install ms-chromium-edge-driver --npm_config_edge_driver_path=/path/to/msedgedriver.exe +npm install ms-chromium-edge-driver --npm_config_edgedriver_path=/path/to/msedgedriver.exe ``` Or add property into your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. ``` -npm_config_edge_driver_path=/path/to/msedgedriver.exe +npm_config_edgedriver_path=/path/to/msedgedriver.exe ``` -Another option is to use the PATH variable `EDGE_DRIVER_PATH` +Another option is to use the PATH variable `EDGEDRIVER_PATH` ```shell -EDGE_DRIVER_PATH=/path/to/msedgedriver.exe +EDGEDRIVER_PATH=/path/to/msedgedriver.exe ``` If both the binary path and driver path are provided, the package will return it skipping browser fetching and driver download steps. +## Download driver during npm install + +Driver is not downloaded during npm install by default. + +To change this behaviour set the npm config property `npm_config_edgedriver_download_on_install` + +```shell +npm install ms-chromium-edge-driver --npm_config_edgedriver_download_on_install=1 +``` + +Another option is to use the PATH variable `EDGEDRIVER_DOWNLOAD_ON_INSTALL` + +```shell +EDGEDRIVER_DOWNLOAD_ON_INSTALL=1 +``` + ## License Licensed under the Apache License, Version 2.0. diff --git a/src/index.ts b/src/index.ts index 1db5123..902869f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,12 +8,12 @@ import { pipeline } from 'stream'; import * as extract from 'extract-zip'; import { getBrowserData } from './browser'; import { osName, isSupportedPlatform, isWin } from './os'; -const cdnUrl = process.env.EDGE_DRIVER_CDNURL || 'https://msedgedriver.azureedge.net'; +const cdnUrl = process.env.EDGEDRIVER_CDNURL || 'https://msedgedriver.azureedge.net'; const mainDir = resolve(__dirname, '..'); const outFile = 'msedgedriver.zip'; -let edgeDriverVersion = process.env.npm_config_edge_driver_version || process.env.EDGE_DRIVER_VERSION; +let edgeDriverVersion = process.env.npm_config_edgedriver_version || process.env.EDGEDRIVER_VERSION; let edgeBinaryPath = process.env.npm_config_edge_binary_path || process.env.EDGE_BINARY_PATH; -let edgeDriverPath = process.env.npm_config_edge_driver_path || process.env.EDGE_DRIVER_PATH; +let edgeDriverPath = process.env.npm_config_edgedriver_path || process.env.EDGEDRIVER_PATH; const forceDownload = process.env.npm_config_edgedriver_force_download || process.env.EDGEDRIVER_FORCE_DOWNLOAD; const edgePathFile = 'paths.json';