electron / chromedriver

Download ChromeDriver for Electron
MIT License
130 stars 60 forks source link

feat: add support for ELECTRON_CHROMEDRIVER_CUSTOM_VERSION #52

Closed dbjorge closed 4 years ago

dbjorge commented 4 years ago

Summary

This PR adds support and documentation for a ELECTRON_CHROMEDRIVER_CUSTOM_VERSION environment variable/.npmrc variable. If set, it will override the library's existing default behavior of using the library version.

Motivation

My team publishes an Electron app that is built against internally-built Electron binaries, and we wanted to be able to test against correspondingly built chromedriver binaries. We wanted to avoid the use of ELECTRON_CUSTOM_FILENAME for this, since the filenames encode platform information and we'd rather keep as much of our build config as possible platform-agnostic. However, the default filename also encodes version information from this library, which mismatches the version produced by the custom build we set in ELECTRON_CUSTOM_DIR. The example included in the README.md update here is an anonymized version of our team's desired use case.

Implementation notes

49 would address this for us, but I wasn't sure how to reasonably address the comments there (it didn't seem thrilling to add a peerDependency on electron to be able to read its package.json version sanely, nor did it seem thrilling to try reading the various types of lockfiles that might exist), so I went with this more manual option instead.

For the specific name of the new config value and the precedence order for checking the assorted env var options, I tried to follow the example of what electron-download does for the similar custom mirror/dir/filename variables (https://github.com/electron/get/blob/master/src/artifact-utils.ts#L27).

The custom version logic intentionally avoids the existing fallback mechanism to x.y.0 used with the default version logic; my expectation is that if someone is setting a custom version, they presumably care to be using exactly the version they say they want to use. It leaves the fallback logic as-is when using the old default-version behavior.

dbjorge commented 4 years ago

@codebytere / @jkleinsc are you the right folks to request a code review from? I'm afraid I'm not familiar with this repo's contribution process.

Thanks!

sirtimid commented 4 years ago

any news on this one?

jkleinsc commented 4 years ago

Version 9.0.0 of chromedriver now allows setting of a custom version by setting the environment variable ELECTRON_CUSTOM_VERSION to the version desired, so this PR is no longer necessary.